Hem*_*mar 2 html asp.net jquery
大家好,我是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>
Run Code Online (Sandbox Code Playgroud)
Dav*_*ang 10
您不能使用自闭标签<script>.你必须以</script>:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.js"></script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
71 次 |
| 最近记录: |