How do I convert the following javascript to using JQuery?
document.getElementById("asc").removeAttribute("href");
document.getElementById("asc").onclick = "";
document.getElementById("asc").style.textDecoration = "underline"
I think I’m close using the below code but this doesn’t quite work.
$('#asc').attr('href', '').click(function() {return false}).css('text-decoration', 'underline');
The only differences I can see is that the
hrefattribute isn’t actually being removed. You’re also creating an event handler when the first example doesn’t have one.This will remove the attribute instead:
If there’s already an
onclickhandler on it, try this: