Calling a $.contains
tool function that detects if a DOM node contains another DOM node, if it contains, returns True, otherwise, returns a value of false, called the format:
$.contains (container, contained);
The parameter container represents a DOM object node element that contains a container for other nodes, and contained is another DOM object node element that is contained by other containers.
<body> <div id= "Divtest" > <div class= "title" > <span class= "FL" > Detection of two-node containment relationships < ;/span> </div> <div class= "content" ></div> </div> <script type= "Text/ja Vascript "> $(function () { varNode_a =Document.body.firstChild; varNode_b =document.body; varstrtmp = "Object Node_a"; if($.contains (node_b,node_a)) {//detect if a node is includedStrtmp + = "contains"; } Else{strtmp+ = "not included"; } strtmp+ = "Object Node_b"; $(". Content"). HTML (strtmp); }); </script></body>
Object Node_a contains object Node_b
JQuery Tool class Function-detects the inclusion relationship of two nodes