0

Hi Editor: this is not a question about: .on('click') vs .click

HTML:

<div id="menu">
    <div id="someID">
        <a href="#">click</a>
    </div>
</div>

jQuery was working, not sure why not working now

$('#menu a').on('click', function(){ alert(8); });

It took me a while to figure out the following is now working, but still not sure why:

$('#menu').on('click', 'a', function(){ alert(8); });
3
  • are the elements dynamically created?
    – Cory
    Commented Dec 31, 2015 at 4:00
  • It is dynamically added
    – SIDU
    Commented Dec 31, 2015 at 4:02
  • Hi Tushar - could you remove the duplicate tag on above?
    – SIDU
    Commented Dec 31, 2015 at 4:08

0

Browse other questions tagged or ask your own question.