Search and processing in jquery
1. Determine whether the object has a http://s.click.taobao.com/t_8? E = 7hz5x % 2bozdswsvvyc5jts79au1q % 3d % 3d & P = mm_24156262_0_0
If the following jqueryCodeIt is unavailable to determine whether an object exists.
If ($ ("# ID ")){
} Else {}
Because $ ("# ID") returns an object regardless of whether the object exists.
Correct use:
If ($ ("# ID"). length> 0) {} else {}
Use the Length attribute of the jquery object to determine whether it exists if it is greater than 0.
Or
If ($ ("# ID") [0]) {} else {}
Or you can directly use the native JavaScript code to determine:
If (document. getelementbyid ("ID") {} else {}
2. Search for Child Nodes Based on the parent node
Jquery children () returns the byte point of the matched object
Children () returns the Child point of the matched object.
<P> one </P>
<Div id = "ch">
<Span> two </span>
</Div>
Jquery code and functions:
Function JQ (){
Alert({{ch}}.children({.html ());
}
$ ("# Ch"). Children (). The result of the object [<span> two </span>. .html () is "two"
3. Find the parent node based on the child node
two
three
jquery code and functions
jquery. ready ({
alert(({{ch}}.children(??sp=}.html ();
});
$ ("# Ch "). obtain the object [ two three ] From children ().
$ ("# Ch "). [ three ]
http://s.click.t Aobao.com/t_8? E = 7hz5x % 2bozdswsvvyc5jts79au1q % 3d % 3d & P = mm_24156262_0_0