?
Solved

How to query attribute values using wildcards

Posted on 2009-07-02
2
Medium Priority
?
895 Views
Last Modified: 2013-11-19
I'm creating a web site that conforms to xhtml 1.1, which excludes the use of the "target" attribute. Instead I'm using rel="external" and the attached jQuery script to open links in new windows.

The script works well, with the exceptions where I also use the "rel" attribute to tag content with the XFN micro format, i.e: rel="external me". In this case the attached script won't match the attribute, since it's not an exact match.

Is there a way in jQuery where I can match attribute values with a wildcard?

The site in question: http://www.fjær.no
$(document).ready( function() {
    
    $('A[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
    
});

Open in new window

0
Comment
Question by:havard-fjaer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 24762649
something like

A[rel*=external]


0
 
LVL 2

Author Closing Comment

by:havard-fjaer
ID: 31599126
Worked perfectly!
Thank you!
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question