Reputation: 57176
How can I return click again after disabling it?
For instance, when the page is loaded I want to turn off all clickable button on the menu,
$(".menu > ul > li > a").click(function(){return false;});
after 3 seconds later, I want to turn them back on, so I am doing this,
var timeout = setTimeout(function() {
$(".menu > ul > li > a").click(function(){return true;});
}, 3000 );
it does not work of course! How can I fix this?
Upvotes: 1
Views: 202
Reputation: 1136
Have you tried out
var timeout = setTimeout(function() {
$(".menu > ul > li > a").unbind('click').click(function(){return true;});
}, 3000 );
Upvotes: 2
Reputation: 16944
You would be better off binding and unbinding the event handler
var handler = function() {
return false;
};
$(".menu > ul > li > a").bind('click', handler);
var timeout = setTimeout(function() {
$(".menu > ul > li > a").unbind('click', handler);
}, 3000);
Upvotes: 3