1

hi i am unable to trigger simple event delegation on my code, The dom elments within selected DIV are dynamically created.

<div class="holder" style="-moz-user-select: none;">
  <a class="jp-previous page1"> previous</a>
  <a class="page">1</a>
  <span class="jp-hidden">...</span>
  <a class="page jp-current">2</a>
  <a class="jp-next page1 jp-disabled">next </a>
</div>

Following is my JS Code which i am executing within ready block.

jQuery("div[class=holder]").on('click',function() {
        alert('i am here');
    });
temp-learn
  • 497
  • 2
  • 9
  • 31

2 Answers2

1

try this....

jQuery(document).on('click','div[class=holder]',function() {
        alert('i am here');
    });

Can also use

 jQuery(document).on('click','.holder',function() {
            alert('i am here');
        });
K.K.Agarwal
  • 836
  • 5
  • 10
1

Try,

jQuery(document).on('click',".holder",function() {
Rajaprabhu Aravindasamy
  • 63,064
  • 13
  • 90
  • 119