I have seen similar threads and have tried the syntax’s in their solutions, but nothing is working.
I want to change the href attribute of all links of a certain type a page, based on the text of the link. Here is what I have now:
$('.class li a').attr('href', '#' + $(this).text());
$(this).text() doesn’t seem to be returning anything. It has been awhile since I’ve worked with jQuery so I am confused by this problem. I have also tried .val() and .html().
In this context,
$(this)is not referencing the currentatag.You can try this: