문제

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.

도움이 되었습니까?

해결책

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');
});

다른 팁

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

$('a').attr('rel','xx');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top