首页javascriptchildren_indexjQuery Selector - 如何选择id为“main”的元素的所有子节点

jQuery Selector - 如何选择id为“main”的元素的所有子节点

我们想知道如何选择id为“main”的元素的所有子节点。


<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
        $(document).ready(function(){
           $("#main > *").css("border", "3px solid red");
        });
    </script>
  </head>
  <body>
      <span id="main">
        <div>asdf</div>
        <button>Child</button>
        <span>A Span</span>
      </span>
    </body>
</html>