Child Filter
Child Filter
Child filter basically handles filtration according to parent-child relationship.
Some main Child filters are given below :
: first-child Selector
It filters all the elements which are first child of their parent.
Example :
$("div span: first-child").css("text-decoration",
"underline")
It filters the first span of each matched div.
: last-child Selector
It filters all the elements which are last child of their parent.
Example :
$("div span: last-child").css({color:"red",
fontSize:"80%"})
It filters the last span of each matched div.
: nth-child Selector
It filters all the elements which are nth child of their parent.
Example : (nthChildSelector.html)
<!DOCTYPE html> |
Output :
Finds the second li in each matched ul and notes it.
: only-child Selector
It filters all the elements which are only child of their parent.
Example : (onlyChildSelector.html)
<!DOCTYPE html> |
Output :
Description of the program
It filters the button with no siblings in each matched div and modify it's look by creating border around it and rename it's name.
Learn from experts! Attend jQuery Training classes.