简体   繁体   中英

Disable click event on ajax loaded content of a DIV

I need to disable click event on ajax loaded content of a DIV.

<div id="left_column">
    <div class="menu">------</div>
    <div class="menu">------</div>
    <div class="small_panel1">------</div>
    <div class="small_panel1">------</div>
</div>

I want disable click event from all div inside leftcolumn.

I am trying below code but it is not working :-

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

Please suggest me what should I use here. Thank in advance

If it's AJAX-loaded content, you need to use event delegation:

$("#left_column").on('click', 'div', function(){ return false; });

You may also need to cancel clicks on the left column container itself:

$("#left_column").on('click', function(){ return false; });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM