的html代碼:非常簡單的jQuery選擇不工作
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ajax</title>
</head>
<body>
<p id="para">this is a sample paragraphe</p>
<script src="my.js" type="text/javascript"></script>
<script src="jquery-1.11.0.min.js" type="text/javascript"></script>
</body>
</html>
my.js文件代碼:
$('#para').click(function(){
$('#para').hide();
alert("para hidden ");
});
我開始學習jQuery的,但似乎我的開始是非常糟糕的,我會找到答案.. 請幫忙
您需要了解的第一件事是,在處理完jQuery之前,jQuery無法在DOM元素上工作。看看jQuery的ready函數。 –