简体   繁体   中英

IE wont fire my jquery's .click function. what could i do?

okay i have the following code below:

SCRIPT:

 <script>
 $(document).ready(function() {
      $(".header").click(function () {
   $(this).effect("bounce", { times:2 }, 200);
     $(".links").show("slow");
   });
 });
 </script>

HTML:

 <body>
   <div class="header">
     <p><img src="images/logo.png" width="438" height="131" alt="Larz Conwell" /></p>
     <p><span class="dash">//</span> Freelance Web Designer &amp; Graphic Artist</p>
   </div> 
   <div class="links">
   </div>
 </body>

and in IE it wont work at all, but it works on all the other browsers. what could be the problem?

also i tried another site i have with jquery on it and it works perfectly.

I think the javascript is getting executed even before the DOM is ready. Try using $.live();

$('.header').live('click', function(){});

This would execute the event even if the class is created later in the DOM.

Are you absolutely certain you have jQuery referenced properly? That is often the cause of an object expected error on $(document).ready() . Using the code you've provided I am able to get IE 8 to fire the click event fine. You can reference jQuery with the following:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript" language="javascript"></script>

have you tried

jQuery(document).ready(function() {

maybe you have noConflist in another script

<script>
$(document).ready(function() {
$('.header').click(function() {
$('.menu').show('slow', function() { 
      });
    });
   });
</script>

this is the code is used to fix it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM