Hi I am using below jquery to add span after anchor tag.
Below is my code :
$(document).ready(function(){
$("a.ext-or-pdf-link").append("<span class=test>test</span>");
});
But this is adding span inside <a> tag but i want to add after <a> in such a way <a ...> text </a><span class=test>test</span>.
Any Idea?
Thanks
You need to use after()
$("a.ext-or-pdf-link").after("<span class=test>test</span>");
.append() adds the passed elements as the last child of the targeted element. So in your case the span will be added as the last child of the anchor instead of adding it as the next sibling
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With