How to enable click functionality of div in javascript or jquery? -


i disabled div using following code

$("#menudiv1").children().bind('click', function(){       return false;  }); 

menudiv contains

<ul>     <li><a class="home" href="#/dashboard">dashboard</a></li>     <li><a class="forms" href="#/viewleads">lead</a></li>     <li><a class="forms"  href="#/viewcases/0">cases</a></li>    </ul> 

but want enable again. how can that?

and there other solution same in angular js?

you can use unbind remove disable click event

 $("#menudiv1").children().unbind('click'); 

to re enable click event use below code.

  function clickfunc(){      // code   }    $("#menudiv1").children().bind('click',clickfunc);  

second option

you can use off remove disable click event

$("#menudiv1").children().off('click'); 

to re enable click event use below code.

  function clickfunc(){      // code   }    $("#menudiv1").children().on('click',clickfunc);  

edit discussed below code avoid click event on a,button tags.

demo

function clickfunc(event){      if(event.target.nodename === 'a' || event.target.nodename == "button"){       return false;      }        // code      alert("click") }  $("#menudiv1").children().on('click',clickfunc);  

Comments