Onclick “li” enable and disable

You just need to do:

$('li.something').unbind('click'); // to disable

To enable you need to rebind the function

$('li.something').bind('click', function() { ...

I don’t know what you want to do, but if you actually want to unbind/bind the event like an (on/off) then you should store the function and just pass it in the bind.

Like:

function foo(){ ... }

$('li.something').unbind('click'); // to disable
$('li.something').bind('click', foo);

Leave a Comment