find方法能找子孙

children方法只能找儿子

<!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>
    <title></title>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
</head>
<body>
<ul>
    <li >
        <ul>
            <li >新闻</li>
            <li>网页</li>
            <li>知道</li>
        </ul>
    </li>
    <li>正文</li>
    <li>结尾</li>
</ul>
</body>
</html>
<script>
    $("#menu_ul").children("ul").css("color", "blue");//只能指定子元素的标签ul 不能指定li 如果换成li的话  不能找到
    $("#menu_ul").find("#li_test").css("background", "green");//可以指定li 
</script>


 

相关文章:

  • 2021-07-31
  • 2022-01-23
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2021-05-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2021-05-24
  • 2022-12-23
  • 2021-09-05
相关资源
相似解决方案