'js runtime error expected object'(第 20 行)或 $(document).ready 开始的位置


<!DOCTYPE html>
<html>
<head>
 <div id="header">
     <center><button type="button" onclick="JavaScript:prompt('so far sogood')">
  click</button></center>
  </div>
 <style type="text/css">                                 
#one{width:100%; height:100px;background-color:red;}
#two{width:100%; height:100px;background-color:green;}
#header{width:100%; height:100px;background-color:yellow;}
</style>
<script type="text/javascript">
$(document).ready(function(
{
$('.one').mouseenter(function()
{
$(this).fadeOut('slow'); 
});
$('.one').mouseleave(function()
    {
 $(this).fadeIn('fast');
}); 
});
</script>

 </head>
<body bgcolor="black">


<div id="one"><center>HELLO</center></div>
 <div id ="two">hello</div>
 </body>

看起来我的问题是,在$(document)发生之后,我的jquery行从哪里开始。显然,在这之前我没有把事情做好。我是jquery的新手,通常我使用外部css页面,所以不同的格式会出现在

您有一个语法错误:就绪函数声明后缺少最后一个括号

$(document).ready(function( {

尝试

    <script type="text/javascript">
        $(document).ready(function() {
            $('.one').mouseenter(function() {
                $(this).fadeOut('slow');
            });
            $('.one').mouseleave(function() {
                $(this).fadeIn('fast');
            });
        });
    </script>

DEMO

最新更新