I am in the process of migrating my live() functions to the on() method in jQuery, however I have come across one little issue that I am unsure about and would very much appreciate some advice.
As the jQuery documentation states, this:
$('.test').live({
click: function(){
alert('.test Clicked')
}
});
Is replaced by this:
$(document).on('click','.test',function(){
alert('.test Clicked')
});
The above is working with no issues (to my knowledge). However, if my selector is slightly more specific like the following, I cannot get it to work:
$(document).on('click',$('.test',element),function(){
alert('.test Clicked')
});
Is it not possible to place selectors into the second parameter? If not, how can I get around this without assigning an ‘id’?
Any help much appreciated
I would expect the line to read: