2
大家好我是一個新的jQuery。在學習過程中,我正在關注此鏈接: http://api.jquery.com/browser/。當我試圖在VS 2010中做這個例子時,我沒有得到確切的輸出結果。但是當我複製這個鏈接中的代碼時,我得到了正確的輸出。請任何人幫助我?這段代碼有什麼問題?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="http://docs.jquery.com" />
<title>index(subject) function</title>
<style type="text/css">
.div_style
{
background-color: Aqua;
font-family: Verdana;
font-size: small;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.js" />
<script type="text/javascript">
$(document).ready(function() {
$("div.div_style").click(function() {
//This is the DOM element clicked
var index = $("div").index(this);
$("span").text("That was div index #" + index);
});
});
</script>
</head>
<body>
<span></span>
<br />
<div class="div_style ">
First Div
</div>
<br />
<div class="div_style ">
Second Div
</div>
<br />
<div class="div_style ">
Third Div
</div>
<br />
</body>
</html>
VS VS與此有什麼關係?它是不是一個html頁面? – 2011-01-27 06:13:53
是的,我在VS裏做這個例子。我也提到過。 – 2011-01-27 06:14:38