Search and replace REL attribute with jQuery -


I want to search the link and change the rel attributes if rel currently equivalent attachement .

I have a code so far:

  $ ("href"). Each (function (index) {$ (this) .attr ('rel', 'group');});    

If you are trying to test some relay value (assuming "Attachment"), all you have to do is:

  $ ('a [rel = "attachment"]'). Attr ('rel', 'group');   

It says that & lt; A & gt; rel = "attachment" , rel with "elements"> for the "group".

On the other hand, if you have all the elements with the href attribute, then you will use something like this

  $ ('[Href] [rel = "attachment"]') attr ('rel', 'group') .;    

Comments