Disable (and re-enable) the href and onclick on elements
Posted
by
jibees
on Stack Overflow
See other posts from Stack Overflow
or by jibees
Published on 2011-01-07T13:26:29Z
Indexed on
2011/01/07
13:53 UTC
Read the original article
Hit count: 141
Hello
I just want to enable / disable onclick and href on elements (a or div).
I don't know how to do this.
I can disable onclick by adding an handler on click event, but the href is still available.
$(this).unbind().click(function(event){
event.preventDefault();
return;
});
FOUND A HACK FOR A ELEMENTS
if ($(this).attr("href")) {
$(this).attr("x-href", $(this).attr("href"));
$(this).removeAttr("href");
}
© Stack Overflow or respective owner