jQuery Selector How to - Select attribute: start with








Question

We would like to know how to select attribute: start with.

Answer


<!--from   ww  w  . ja va  2  s .com-->
<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $("input[name^='A']").val("data");
    });
    </script>
  </head>
  <body>
      <input name="Abc" />
      <input name="Bcd" />
      <input name="Cde" />
  </body>
</html>

The code above is rendered as follows: