shortysbest Posted January 30, 2011 Share Posted January 30, 2011 why doesn't the jquery click() work in IE? Well, not all versions of IE, there were some versions it worked, now I have the newest version (9.0.7930.16406), and older some of the older versions do not work either. this is how I do it: $(document).ready(function(){ $("#login").click(function(){ //code to execute here }); }); Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/ Share on other sites More sharing options...
.josh Posted January 30, 2011 Share Posted January 30, 2011 All by itself that should work in IE6-8. Can't speak for IE9 since that's kinda new and in beta...but I don't see why it shouldn't. Maybe it is something within there (that //code to execute here) that isn't working? Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167426 Share on other sites More sharing options...
shortysbest Posted January 30, 2011 Author Share Posted January 30, 2011 I just have $(document).ready(function(){ $("body").click(function(){ alert('a'); }); }); and it doesn't work in IE, it does however work in firefox/safari. Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167429 Share on other sites More sharing options...
.josh Posted January 30, 2011 Share Posted January 30, 2011 okay so now I'm confused. is your .click() for #login or body? Or are you saying that you have that 2nd bit of code inside the first? Post your full code and also specifically which version(s) of IE it doesn't work in Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167433 Share on other sites More sharing options...
shortysbest Posted January 30, 2011 Author Share Posted January 30, 2011 The code I just posted above is a completely separate piece of code, it has nothing to do with the login. I used that for a clean simple test to check whether or not it was a piece of my code, or just the jquery click() that wasn't working in IE. I posted the version of IE that I am using that it does not work in, I know I had this issue on older versions of IE as well, on older computers at school, but it worked fine on my computer which had IE 8. Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167434 Share on other sites More sharing options...
.josh Posted January 30, 2011 Share Posted January 30, 2011 The only thing I can think of is that 'body' is part of the page but it's not ALL of the page, so you can't necessary click anywhere in your window and see the popup. Or else, it may or may not happen depending on what browser (version) you use. I mean for instance, with nothing else except for that snippet of code, I personally don't expect to be able to see that alert when clicking anywhere in the browser, because you don't actually have any html or body tag or anything. Even if the browser auto-generates those tags for you...why should the body tag span the entire window when you have nothing in it? I know it's an example, but for instance: $(document).ready(function(){ $(document).click(function(){ alert('a'); }); }); That works for me, even in IE8. Point being that even without any html or anything, everywhere in the browser window is somehow part of the document. Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167442 Share on other sites More sharing options...
.josh Posted January 30, 2011 Share Posted January 30, 2011 but anyways, "body" and "document" is not the same as "#login" at all. You will have to post the context of where "#login" is. Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167444 Share on other sites More sharing options...
shortysbest Posted January 30, 2011 Author Share Posted January 30, 2011 Oh, I know that, the page I tested it on had a good amount of body space on it, it wasn't blank, and my point was that it worked in firefox, but not in IE (when clicking inside body) (and also, that code you just gave me works in firefox but not in IE.) Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167445 Share on other sites More sharing options...
shortysbest Posted January 30, 2011 Author Share Posted January 30, 2011 Well, the #login instance was just an example of how I am using jquery click(), the fact is that click() doesn't work at all in certain versions of IE Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167446 Share on other sites More sharing options...
.josh Posted January 30, 2011 Share Posted January 30, 2011 Well I tried the code myself and it worked just fine in IE8. Are you sure you have javascript turned on in your browser? Looking at the right file? Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167448 Share on other sites More sharing options...
shortysbest Posted January 30, 2011 Author Share Posted January 30, 2011 Yeah, I know it worked in IE 8, but it doesn't work in all versions, like the new IE 9 Beta, and older versions older then 8 (not sure exactly which ones though) Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167450 Share on other sites More sharing options...
.josh Posted January 30, 2011 Share Posted January 30, 2011 p.s. - not a fact that click() doesn't work at all in certain versions of IE. With very few exceptions, the core jquery.js library MUST work for all major browsers and versions, otherwise it wouldn't be put into it. I am quite sure it is some problem on your end, be it something in my previous post or else a problem in some other part of your code that you aren't showing. I mean even here you keep saying inconsistent things. You say that you tested with ONLY that code but then turn around and say that you are testing it somewhere that has lots of other code. You JUST said in your previous post that it did not work in IE8..but then you are now saying it does! And now you are claiming it doesn't work in older versions but then can't say which ones. The bottom line is that if a core jquery method being used in an extremely basic example did not work in these major browser versions as you claim, it would be a well known issue. The reason it's not working is not because .click() doesn't work, it's because you are either not using it correctly or else you had some browser setting turned off or disabled or not pointing to the right file, etc... I'm sorry, but that's just how it is. I'm not trying to fight here...I'm here to help, not fight. But you aren't going to solve your problem unless you stop making assumptions and be more accurate in your posts. Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167454 Share on other sites More sharing options...
.josh Posted January 30, 2011 Share Posted January 30, 2011 Maybe your schools are using IE5 or something. Schools have a tendency to use outdated stuff. As mentioned previously, jQuery works for IE6+. And as far as IE9...IE9 just went from preview to beta. You cannot expect things to work 100% in a beta. But nonetheless, so far I did some quick research and I am not seeing any reports of problems with .click() and IE9. But if you really think there is some kind of bug with IE9 then I suggest you report it on jquery.com Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167461 Share on other sites More sharing options...
shortysbest Posted January 30, 2011 Author Share Posted January 30, 2011 alright, yeah I made an entirely new site, and I took the latest Jquery framework off of their site and tested this page with it, again worked fine in firefox, but not in IE9. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript" src="jquery.js"></script> </head> <body> <script> $(document).ready(function(){ $(document).click(function(){ alert('a'); }); }); </script> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167478 Share on other sites More sharing options...
.josh Posted January 30, 2011 Share Posted January 30, 2011 Okay well then... Maybe your schools are using IE5 or something. Schools have a tendency to use outdated stuff. As mentioned previously, jQuery works for IE6+. And as far as IE9...IE9 just went from preview to beta. You cannot expect things to work 100% in a beta. But nonetheless, so far I did some quick research and I am not seeing any reports of problems with .click() and IE9. But if you really think there is some kind of bug with IE9 then I suggest you report it on jquery.com Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167481 Share on other sites More sharing options...
haku Posted January 31, 2011 Share Posted January 31, 2011 I'm thinking that maybe IE doesn't fire a click event for the body element. I could be wrong, it's purely a hypothesis, but it wouldn't surprise me at all. Test it in pure javascript to see: body.onClick = function(){alert("ninja");} Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167658 Share on other sites More sharing options...
shortysbest Posted January 31, 2011 Author Share Posted January 31, 2011 Nothing happens, in either firefox nor Internet Explorer, and it's not just the body element it doesn't work on, I was just using this as an example, What I have it for is for the button to login and sign up, as well as with other stuff. Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167661 Share on other sites More sharing options...
haku Posted January 31, 2011 Share Posted January 31, 2011 You probably have an error somewhere in your javascript then - this can prevent all javascript on a page from working. Are you using firefox with firebug? If not, install firebug on firefox, and then open the page with the firebug window open, it will show you where the errors lie in your code. Quote Link to comment https://forums.phpfreaks.com/topic/226142-jquery-click-doesnt-work-in-ie/#findComment-1167744 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.