jQuery Method How to - Use children() to Get Children from DIV








Question

We would like to know how to use children() to Get Children from DIV.

Answer


<!-- w  ww. ja  va2  s.  c  o m-->
<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("div").children().css("border", "3px double red");
        });
    </script>
  </head>
  <body>
      <div><span>span</span>div</div>
  </body>
</html>

The code above is rendered as follows: