2012-09-26 54 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> 
相關問題