Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I dynamically enable/disable links with jQuery?

I have some links displayed on a page. I would like to enable/disable them based on other events on the page. Is there a way to do this with jQuery?

like image 456
GSto Avatar asked Sep 24 '10 16:09

GSto


People also ask

How do I set disabled property in jQuery?

The disable/enable an input element in jQuery can be done by using prop() method. The prop() method is used to set or return properties and values for the selected elements.

How do I enable and disable a link in HTML?

preventDefault() if $(this). data('disabled') is true, and then set data('disabled', true) to any link I want to disable (false to enable, etc.)


1 Answers

$('selector_for_links_to_disable').bind('click', function(e){         e.preventDefault(); }) 

and for enabling:

$('selector_for_links_to_enable').unbind('click') 
like image 121
dekomote Avatar answered Sep 27 '22 18:09

dekomote