Javascript jQuery动画在IE9中不起作用&;火狐5

Javascript jQuery动画在IE9中不起作用&;火狐5,javascript,jquery,jquery-animate,Javascript,Jquery,Jquery Animate,这是消息来源,我遗漏了什么吗? 我试过了,效果不错,但在我的电脑上不起作用。 --编辑 我使用了jQueryMinv1.4.1,它不起作用,所以我下载了最新版本,仍然不起作用,在我使用谷歌jQuerySDN的链接上,它是v1.5.1 <html> <head> <title>Test</title> <script src="jquery-1.6.2.min.js" type="text/javascript">

这是消息来源,我遗漏了什么吗?
我试过了,效果不错,但在我的电脑上不起作用。
--编辑
我使用了jQueryMinv1.4.1,它不起作用,所以我下载了最新版本,仍然不起作用,在我使用谷歌jQuerySDN的链接上,它是v1.5.1

<html>
    <head>
    <title>Test</title>
    <script src="jquery-1.6.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $('document').ready(function() {
        $('#bio > div').hide();
        $('#bio > div:first').show();
    });
    $('#bio h3').click(function() {
        alert('called');
        $(this).next().animate(
            {'height':'toggle'}, 'slow', 'swing'
        );
    });
    $('p:first').animate(
        {
        height: '+=100px',
        backgroundColor: 'green'
        },
        {
            duration: 'slow',
            easing: 'swing',
            complete: function() {alert('done!');},
            queue: false
        }
    );
    </script>
    </head>
    <body>

        <div id="bio">
            <h2>Who’s Hot Right Now?</h2>
            <h3>Beau Dandy</h3>
            <div>
                <img src="../images/beau_100.jpg" width="100"
                    height="100" alt="Beau Dandy"/>
                <p>Content about Beau Dandy</p>
            </div>
            <h3>Johnny Stardust</h3>
            <div>
                <img src="../images/johnny_100.jpg" width="100"
                height="100" alt="Johny Stardust"/>
                <p>Content about Johny Stardust</p>
            </div>
            <h3>Glendatronix</h3>
            <div>
                <img src="../images/glenda_100.jpg" width="100"
                    height="100" alt="Glendatronix"/>
                <p>Content about Glendatronix</p>
            </div>
        </div>
    </body>
</html>

试验
$('document').ready(函数(){
$('#bio>div').hide();
$('#bio>div:first').show();
});
$('#bio h3')。单击(函数(){
警报(“被呼叫”);
$(this).next().animate(
{'height':'toggle'},'slow','swing'
);
});
$('p:first')。设置动画(
{
高度:'+=100px',
背景颜色:“绿色”
},
{
持续时间:“慢”,
放松:"摇摆",,
完成:函数(){alert('done!');},
队列:false
}
);
现在谁很性感?
花花公子
关于花花公子的内容

约翰尼星尘 关于约翰尼星尘的内容

格伦达特罗尼克斯 关于Glendatronix的内容


我认为您的
文档.ready
关闭得太早了

我只是简单地移动了括号(代码)到脚本的结尾

<script type="text/javascript">
$('document').ready(function() {
    $('#bio > div').hide();
    $('#bio > div:first').show();
    $('#bio h3').click(function() {
        alert('called');
        $(this).next().animate(
            {'height':'toggle'}, 'slow', 'swing'
        );
    });
    $('p:first').animate(
        {
        height: '+=100px',
        backgroundColor: 'green'
        },
        {
        duration: 'slow',
        easing: 'swing',
        complete: function() {alert('done!');},
        queue: false
        }
    );
});
</script>

$('document').ready(函数(){
$('#bio>div').hide();
$('#bio>div:first').show();
$('#bio h3')。单击(函数(){
警报(“被呼叫”);
$(this).next().animate(
{'height':'toggle'},'slow','swing'
);
});
$('p:first')。设置动画(
{
高度:'+=100px',
背景颜色:“绿色”
},
{
持续时间:“慢”,
放松:"摇摆",,
完成:函数(){alert('done!');},
队列:false
}
);
});
为什么??例如,您试图将事件(如
.click()
绑定到名为
#bio h3
的元素。但是,元素
#bio h3
可能还不存在于DOM中,因为您正在
中调用脚本。使用
document.ready
确保DOM在中执行代码之前存在


它在某些浏览器中工作的原因很可能是一个简单的计时问题。

请详细定义“不工作”。切换不会设置动画。当我单击标题时,没有任何切换。没有人提到动画工作。@Marc,这里你指的是在jsfiddle上?如果是,是的,我提到过。它在我的电脑和笔记本电脑上都不工作。我可能出错了什么?|谢谢,现在我收到警报说它已被调用,但不会显示/隐藏div。这应该可以解决问题。您需要在$('document').ready(function(){})内定义事件等;或$(函数(){});在FF中也可以,但在IE中不行。jQuery不应该是可移植的吗?基本上是的。有时,新的浏览器或版本附带了新的设置,这可能会使其不稳定,并在较新的版本中得到解决。尝试将“show()”更改为:$('#bio>div:first child')。show();或$('#bio>div').eq(0.show();仍然不工作,内容未完全呈现。只显示一行而不是图像,文本不显示。不过还是要谢谢你的帮助。