[Solved] jQuery how to disable event handle


Remove hash from <li id='#myElement'>. Correct syntax is :

<li id='myElement'>

$('#myElement').on("click", function() {...

Then

$('#myElement').off("click")
// or
$('#myElement').css('pointer-events', 'none');

will both work (but not 'pointer-evenet')…

Demonstration :

$('#myElement').on("click", function() {
    alert('Hello world');
});

$('#myElement').css('pointer-events', 'none');

// or : 
// $('#myElement').off("click");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<li id='myElement'>
    <a href="#">Click here</a> (nothing should happen)
</li>

solved jQuery how to disable event handle