Anyone know how to disable a link in jquery WITHOUT using return false;
?
Specifically, what I'm trying to do is disable the link of an item, performing a click on it using jquery which triggers some stuff, then re-enabling that link so that if it's clicked again it works as default.
Thanks. Dave
UPDATE
Here's the code. What it needs to do after the .expanded
class has been applied is to re-enable the disabled link.
$('ul li').click(function(e) {
e.preventDefault();
$('ul').addClass('expanded');
$('ul.expanded').fadeIn(300);
//return false;
});
html link example:
use this in jQuery
add this to css :
You should find you answer here.
Thanks @Will and @Matt for this elegant solution.
unbind()
was deprecated injQuery 3
, use theoff()
method instead:Here is an alternate css/jQuery solution that I prefer for its terseness and minimized scripting:
css:
jQuery:
Try this:
EDIT-
From your updated code:
My fav in "checkout to edit an item and prevent -wild wild west clicks to anywhere- while in a checkout" functions
So if i want that all external links in a second action toolbar should be disabled while in the "edit-mode" as described above, i'll add in the edit function
Link example after fire:
And now you CAN use disabled property for links
Cheers!