Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery make image elements non active in clickable div
    text
    copied!<p>I have a div class that when clicked toggles an animation. Within this div (one of a number with the same class name) are a number of img icons. I want to maintain the click on the div but not on the images inside the div - ultimately the images will fire another function when clicked.</p> <p>So far my JQuery code is as follows:</p> <pre><code>$(document).on('click', '.list_body', function() { $(this).nextAll('.list_info:first').slideToggle(500); return false; }); $('.list_body').on('click', 'img', function(e){ e.preventDefault(); alert("Test"); }); var ls="&lt;div class='list_body'&gt;&lt;div class='lister'&gt;&lt;img src='"+path+stat1+"' /&gt;&lt;img src='"+path+stat2+"' /&gt;&lt;img src='"+path+stat3+"' /&gt;&lt;img src='"+path+stat4+"' /&gt;&lt;img src='"+path+stat5+"' /&gt;&lt;/div&gt;&lt;div class='lister'&gt;"+split_stats[5]+" "+split_stats[6]+" "+split_stats[7]+"&lt;br /&gt;["+split_stats[12]+"]"+"&lt;/div&gt;&lt;div class='lister'&gt;"+split_stats[13]+"&lt;/div&gt;&lt;div class='lister'&gt;&lt;a href='javascript:void(0);' class='lister_a'&gt;View Appointment &amp;amp; Actions&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;" ls+="&lt;div class='list_info'&gt;"; ls+="&lt;ul class='add1'&gt;&lt;li&gt;"+split_stats[8]+"&lt;/li&gt;&lt;li&gt;"+split_stats[9]+"&lt;/li&gt;&lt;li&gt;"+split_stats[10]+"&lt;/li&gt;&lt;li&gt;"+split_stats[11]+"&lt;/li&gt;&lt;li&gt;"+split_stats[12]+"&lt;/li&gt;&lt;/ul&gt;"; ls+="&lt;ul class='add2'&gt;&lt;li&gt;&lt;strong&gt;Tel: &lt;/strong&gt;"+split_stats[14]+"&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Mobile: &lt;/strong&gt;"+split_stats[15]+"&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Email: &lt;/strong&gt;"+split_stats[16]+"&lt;/li&gt;&lt;li&gt;&lt;strong&gt;Job ID: &lt;/strong&gt;"+split_stats[17]+"&lt;/li&gt;&lt;/ul&gt;"; ls+="&lt;div class='bottom_links' data-job_id='"+split_stats[17]+"'&gt;&lt;div class='lister'&gt;&lt;a href='javascript:void(0);' data-ref1='1' data-job_id='"+split_stats[17]+"'&gt;Print Files&lt;/a&gt;&lt;/div&gt;&lt;div class='lister' data-ref1='2'&gt;&lt;a href='javascript:void(0);' data-ref1='2' data-job_id='"+split_stats[17]+"'&gt;Add Message&lt;/a&gt;&lt;/div&gt;&lt;div class='lister'&gt;&lt;a href='javascript:void(0);' data-ref1='3' data-job_id='"+split_stats[17]+"'&gt;Add Tracking No.&lt;/a&gt;&lt;/div&gt;&lt;div class='lister'&gt;&lt;a href='javascript:void(0);' data-ref1='4' data-job_id='"+split_stats[17]+"'&gt;///&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;"; ls+="&lt;/div&gt;"; $(ls).appendTo('.list_holder'); $('.list_info').hide(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload