Wednesday, September 29, 2010

jQuery Selectors: Select elements using Id

Selecting HTML elements with Id.

syntax:
$("#elementid")

The # selector selects an element with a unique id.

eg:
write the following in html head section
<script type="text/javascript">
$(
}
function DisplayAll() {"#divDetails").text("Welcome to my first jQuery application.");</script>

write the following in the body.

<div id="divDetails"></div><hr />
<div></div><hr /><div></div><hr /><div></div><hr />

No comments: