Whats the wrong in this code?
Hi everyone I am a new to jQuery. While learning I am following this link: http://api.jquery.com/browser/. When I am trying to do this example in VS 2010 I'm not getting the exact output. But when I was copying the code which is in this link I was getting the correct output. Please could any one help me?
<!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>
You can't use self closing tags for <script>
. You must end with a </script>
:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.js"></script>
精彩评论