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 & 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.
精彩评论