jQuery ID selector
Syntax for ID selector
$('#myid')
selects the unique element with an ID equal to myid
.
Examples
$('#myid')
selects the unique element withid="myid"
.$('p#myid')
selects a single paragraph with an ID ofmyid
.$("div#elementId")
selects all divs with an ID ofelementId
.
<!DOCTYPE html>
<html>
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js">
</script>
<script>
$(document).ready(function(){
var wrappedElements = $("ul#myList");
document.writeln(wrappedElements.length);
});<!--from w ww . j av a2s.c om-->
</script>
<body>
<div id="main">
<ul id="myList">
<li>foo</li>
<li>bar</li>
</ul>
</div>
</body>
</html>