Wednesday, 11 June 2014

How to find Li position in html


<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var xx = $('ul li#end').index();
alert(xx);
});
</script>
</head>
<body>
<div class="nav-collapse collapse">
<ul>
<li>Test </li>
<li>Test </li>
<li>Test </li> <li id="end">Tes</li>
<li>Test </li>
<li>Test </li>
<li>Test </li>
<li>Test </li>
<li>Test </li>
<li>Test </li>
<li>Test </li>
<li>Test </li>
</ul>
</div>
</body>
</html>