Reputation: 17586
hi i have a image and i want to add a click event to this image field .
the problem is click event working on chrome , but not working on firefox
HTML
<img class="facebook_connect" src="http://localhost/elephanti2/assets/frontend/ivory/images/fb-button.png" alt="Sign up with Facebook">
JQUERY
jq('.facebook_connect').live('click',function(){
alert("");
var url= baseurl+"connections/facebook_connector/invite_friends_popup";
window.open(url, 'Facebook', 'height=500,width=800');
});
in chrome the alert
and window.open
both work , in firefox it is not working . why is that ,please help........................
Upvotes: 0
Views: 1561
Reputation: 395
Maybe try .bind
to a container instead of .live
:
$('#cont').bind('click', function(e){
if($(e.target).is('.facebook_connect')){
// some actions
})
By the way:
As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().
Upvotes: 1
Reputation: 8379
Try this script
$('img.facebook_connect').bind('click',function()
{
alert('Clicked on the URL'+$(this).prop('src'));
// Write your next code here.. This will work in all browsers..
});
Here is the fiddle to check http://jsfiddle.net/ebG9N/1/
Thanks
Upvotes: 2