jquery - Event listener don't work -
i have next selector "#btn-similar", why listener works:
$("#btn-similar").click(function(e){ console.log("similar click"); });
but listener not:
$(document).on("click", "#btn-similar", function(e){ console.log("similar click"); });
the html markup is:
<div id="btn-similar" class="details-tab active-nav"> <span class="angle"></span> <div class="title">overview</div> </div>
i using jquery 1.10, ideas ?
since both pieces of code correct , work in circumstances, can think of these reasons why second 1 not work:
there's
<a>
tag or form post in hierarchy causing browser go new page before results of code can seen.you have more 1 object in page
id=btn-similar
.there's script error right before second block of code keeps executing.
you have typo somewhere , code doesn't match desired id. in question, show code refers
id=btn-similar
, codeid=btn-overview
.
fyi, can see second block of code work fine here: http://jsfiddle.net/jfriend00/8s7rukt3/ there's oddity in page haven't disclosed.
Comments
Post a Comment