Jquery prepend <span> without automatically adding a closing tag
I am trying to add a tag <span>around the contents of a tag <a>.
HTML outputs without js as follows:
<a href="#">Link Here</a>
I would like to add <span>inside the link as follows:<a href="#"><span>Link Here</span></a>
My idea was to “add” the opening gap and “add” the closing tag to a, however I cannot go past the prefile. When I try to add a span, it automatically adds a closing tag </span>. Here is the script I am using
$(document).ready(function () {
$('a.button2').prepend('<span>');
});
Here is what he does:
<a href="#"><span></span>Link Here</a>
Is there a way to add an ONLY open tag so that I can add a close later or another solution to this problem?
+3
1 answer