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? 回答1: $('selector_for_links_to_disable').bind('click', function(e){ e.preventDefault(); }) and for enabling: $('selector_for_links_to_enable').unbind('click') 回答2: You could do something like: $('.links').click(function(e){ if( [some conditions] ){ e.preventDefault(); } }); Be sure to show that they no longer work somehow, otherwise your users