Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace the A tag with the any other tag

Tags:

html

jquery

css

I have the following code structure,

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

I am selecting the 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>

let me know how to do it using jQuery.

like image 485
kalpesh Avatar asked Feb 02 '26 09:02

kalpesh


1 Answers

Try this:

jQuery('a[href="sample-test"]').replaceWith($('<abbr>' + this.innerHTML + '</abbr>');
like image 93
Sarfraz Avatar answered Feb 05 '26 02:02

Sarfraz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!