Text I select a using jQuery selec...">

Replace tag A with any other tag

I have the following code structure,

<a href="sample-test"> Text </a>

      

I select a using jQuery selector,

jQuery('a[href="sample-test"]').css({'backgroundColor' : 'yellow'}); 

      

and I want to replace the tag with any tag like <abbr></abbr>

please let me know how to do this using jQuery.

+2


a source to share


1 answer


Try the following:



jQuery('a[href="sample-test"]').replaceWith($('<abbr>' + this.innerHTML + '</abbr>');

      

0


a source







All Articles