Prevent Mouse Clicks

by Kyle Mitofsky

HTML

<p>Click on list items to see alert</p>

<ul >
    <li>Enabled</li>
    <li class="prevent">Disabled</li>
</ul>








<!-- Post Info -->
<div style='position:fixed;bottom:0;left:0;    
            background:lightgray;width:100%;'>
    About this SO Post: <a href='http://stackoverflow.com/q/18896727/1366033'>Disable mouse in tag “li”</a><br/>
    jQuery API: <a href='http://api.jquery.com/unbind/'>.unbind() method</a><br/>
    Find Documentation: <a href='https://developer.mozilla.org/en-US/docs/Web/CSS/cursor'>MDN Css Cursor</a><br/>
<div>

CSS

.box {
    background: #ccddff;
    padding: 20px;
    margin: 20px;
}
.prevent {
    cursor:not-allowed;
}

JavaScript

$(function() {
    
    $('li').click(function(e) {
        alert("say hello!");
    });
      
    $('.prevent').unbind();

});