2012-09-26 55 views
0

我在jquery中写了非常小的代码,但我无法执行它我在哪里错了?为什么这个jQuery代码不适合我?

<html> 
<head> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js">  
<script type="text/javascript"> 
$(document).ready(function(){ 
    $("p").click(function(){ 
    $(this).hide(); 
    }); 
}); 
</script> 
</head> 

<body> 
<p>If you click on me, I will disappear.</p> 
</body> 

</html> 

任何帮助将大大appriciated。

+0

检查您的JavaScript控制台。看看是否有任何错误。 –

回答

2

你忘了关闭脚本标签

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"> </script> 
3

您忘记关闭jquery的脚本标记。它应该是这样的:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> 
<script type="text/javascript"> 
    $(document).ready(function() { 
     $('p').click(function() { 
      $(this).hide(); 
     }); 
    }); 
</script> 

通知收盘</script>标签

3

你没有关闭第一个脚本标签:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script> 
0

关闭头标记内的脚本标记。

<html> 
<head> 
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"> </script> 
    <script type="text/javascript"> 
    $(document).ready(function(){ 
    $("p").click(function(){ 
    $(this).hide(); 
    }); 
    }); 
    </script> 
</head> 

<body> 
    <p>If you click on me, I will disappear.</p> 
</body> 

</html> 
相关问题