jQuery Selector How to - Select all input descendants of forms








Question

We would like to know how to select all input descendants of forms.

Answer


<!-- w w w  . j  av a2 s. c  om-->
<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
        $(document).ready(function(){                
           $("form input").css("border", "2px solid blue");                
        });
    </script>
  </head>
  <body>
        <form>
            <input name="name" />
            <input name="newsletter" />
        </form>
  </body>
</html>

The code above is rendered as follows: