日期:2014-05-16  浏览次数:20346 次

jquery问题
请问find()和children()有什么区别?

------解决方案--------------------
http://www.baidu.com/s?tn=baiduhome_pg&bs=jquery+find%BA%AF%CA%FD%BA%CDchildren%BA%AF%CA%FD%C7%F8%B1%F0&f=8&rsv_bp=1&wd=jquery+children&inputT=4010

第2个就是你要的答案 我网速慢 打不开
------解决方案--------------------
HTML code

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="gb2312" />
        <title></title>
        <style>
        </style>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
    </head>
    <body>
        <div id="a">
            <span>
                1
                <span>
                    2
                    <span>3</span>
                </span>
            </span>
        </div>
        <div id="b">
            <span>
                1
                <span>
                    2
                    <span>3</span>
                </span>
            </span>
        </div>        
        <script>
            alert(  $('#a').children('span').length )  //1
            alert(  $('#a').find('span').length ) //3
        </script>
    </body>
</html>