-1

I use a little jQuery script to run a simple music player, but I'd like to add a rel="player" to the links in this jQuery script (the play/stop button for instance). This way I can exclude these rel="player" links from another jQuery script I use, because I don't want it to take the rel="player" elements into account.

I reckon this is fair simple but I don't really know how to to it.

Here is the jQuery script of the player, if it's ever necessary.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Xavier
  • 87
  • 1
  • 10

2 Answers2

0

You can use this to add the rel to all the links

$('a').attr('rel','xx');
Zephyr
  • 45
  • 2
0

This should take care of ALL the links. If you don't want all the links you need to be specific about which link you want.

$('a').each(function () {
   $(this).attr('rel', 'xx');
});
Brian Noah
  • 2,962
  • 18
  • 27
  • I guess it works but not in my case actually. I have this line of script (for another jquery script) `$('a').not("a[rel*=shadowbox]").each(function(i,el){` Is it possible to actually add there a rel attribute? So I could just use this rel, and I wouldn't have to exclude others. – Xavier Oct 14 '12 at 09:44
  • $('a:not[rel*=""]') is a little cleaner, but yup that should work. – Brian Noah Oct 14 '12 at 09:48