[jquery] jQuery 选择器>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title></title>  
  
<!-- 引入jQuery -->  
<script src="../js/jquery-1.4.3.js" type="text/javascript"></script>  
<script type="text/javascript">  
$(function(){   
    var $s =$("#test>div");  
    var $t = $("#test div");  
    alert($s.length);//获取子节点  3  
    alert($t.length);//获取子节点及其下属的子节点 5  
     
})  
</script>  
</head>  
<body>  
    <div id="test">  
            
        <div id="test1">  
               
            <div id="test11">  
                  
                  <div id="test111">  
                  
                  
                    
                    </div>  
                    
            </div>  
              
        </div>  
          
          
        <div id="test2">  
              
        </div>  
          
        <div id="test3">  
              
              
        </div>  
              
          
          
          
    </div>  
</body>  
</html>  
</span>  

 

posted @ 2016-01-11 09:40  snow__wolf  阅读(170)  评论(0编辑  收藏  举报