Tuesday, September 14, 2010

Using jQuery Selectors : Using tag name

Using jQuery Selectors
  tag name, ID, and class. They can be used either on their own or in combination with other selectors.             
Three building blocks of selectors are

Selecting HTML elements with tag name.


The following example demonstrates how to select all div elements and assign a text value into it within  an HTML page.
syntax:
 $(element name)  : which returns all matched html elements.
 $('element name').text('text to display'); : which assign the text value into all matched element.
Eg:
Add following in html head

<script type="text/javascript">
$(
}
function DisplayAll() {"div").text("Welcome to my first jQuery application.");</script>
Add following in html body

<input id="Button1" type="button" value="Display Text onclick="DisplayAll()" /><div></div><hr />
<div></div><hr /><div></div><hr /><div></div><hr />

Introduction to jQuery & What jQuery does

Introduction to jQuery

jQuery is a library of JavaScript Functions, ie; a group of built-in javascript function to improve the interaction with web development.

Using jQuery you can do the following:
  • Simplify common JavaScript tasks
  • Access HTML elements in a document
  • HTML element manipulation
  • Modify the appearance of a web page
  • Manipulate CSS properties 
  • Alter the content of a document
  • Respond to a user's interaction
  • Animate changes being made to a document. 
  • Retrieve information from a server without refreshing a page ( AJAX).
  •