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?
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.
preventDefault() if $(this). data('disabled') is true, and then set data('disabled', true) to any link I want to disable (false to enable, etc.)
$('selector_for_links_to_disable').bind('click', function(e){ e.preventDefault(); })
and for enabling:
$('selector_for_links_to_enable').unbind('click')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With