jquery - Custom class in an array loop wont work -
i trying use class (question) attached in each element of array, loop works fine. problem when try use class in jquery nothing happens, if not there...
i aware angular adds ng-scope , ng-binding classes, preventing jquery maybe?
when inspect dom theres no errors , class there , wont work!
here code: html
<p ng-repeat="n in ['human or lemar king?','name of tribe?','can boogie?'] | filter:query" class="question"> {{n}}</p> jquery
$(function () { $(".question").on('click',function() { alert("ohh hail king julien!") }); });
you're trying set event handler on elements aren't in dom tree yet.
you can either go angular way , add ng-click:
<p ng-click="dosomething()" ng-repeat="n in ['human or lemar king?','name of tribe?','can boogie?'] | filter:query" class="question"> {{n}}</p> or can set live event on <body> (or on closer parent of element present in dom):
$(function () { $('body').on('click', '.question', function() { alert("ohh hail king julien!") }); });
Comments
Post a Comment