Reputation: 8379
I am attaching an event to all elements with classname of element
inside the main
container like below
$('#main').delegate('.element','click', function(){
console.log($(this).html());
});
But the problem is the click event is fired when double click in Windows Chrome browser and in Mac it is fired with single click.
Browser : Google Chrome OS tested : Windows8 and Mac jQuery version : jQuery 1.10.2
Upvotes: 1
Views: 59
Reputation: 1792
Try this :
$(document).delegate('.element','click', function(){
console.log($(this).html());
});
instead
$('#main').delegate('.element','click', function(){
console.log($(this).html());
});
Hope it will help
Upvotes: 0
Reputation: 11293
From the .delegate() docs :
As of jQuery 1.7, .delegate() has been superseded by the .on() method. For earlier versions, however, it remains the most effective means to use event delegation. More information on event binding and delegation is in the .on() method. In general, these are the equivalent templates for the two methods:
Try using .on() :
$('#main').on('click','.element', function(){
console.log($(this).html());
});
Upvotes: 1