在 MouseOver 和 MouseOut 上调用 jQuery 函数

2 html javascript css jquery

我有以下代码:

<script src="http://code.jquery.com/jquery-1.5.js" type="text/javascript">
  $(function() {
    $('.webPanel').mouseover(function(){
        $('.webPanel').animate({'width': '350px'}, 100);

      });
  });
</script>
Run Code Online (Sandbox Code Playgroud)

哪个不起作用。正如您可能会说的,它应该在鼠标悬停时将 .webPanel div 扩展到 350px,但没有任何反应。

我怎样才能让这件事发挥作用?我不明白为什么它不起作用!

谢谢

Dar*_*rov 5

您需要为 jquery 添加一个单独的脚本:

<script src="http://code.jquery.com/jquery-1.5.js" type="text/javascript"></script>
<script type="text/javascript">
  $(function() {
    $('.webPanel').mouseover(function(){
        $('.webPanel').animate({'width': '350px'}, 100);

      });
  });
</script>
Run Code Online (Sandbox Code Playgroud)