Friday 9 December 2011

Parents and Children Selectorswith jQuery


The following code shows two
elements, each with the same content inside:







My Test Page











your name goes here

text here



another name goes here

More text here







more name

more text



another name

More text











select elements based on their parents or children, try these selectors:



first-child: Selects the first child element. The following code selects the first child of the first
and changes the text of the selected element:

$(‘div:first-child’).text(‘Change me.’);


last-child: Selects the last child element. The following code selects the last child of the second
and changes the text of the selected element:

$(‘div:last-child’).text(‘Change me.’);


child: Selects the child element of the parent element. This code changes the text of every element that is a child of a
element


$(‘div > strong’).text(‘Change me.’);


You can find the complete list of selectors at http://api.jquery.com/category/selectors/.


Meta tag generator 4 seo
If else statement
Increase traffic your blogs
Popularity by massage
Tips 4 blog posting



No comments:

Post a Comment