jQuery Form How to - Capitalize select and input text field








Question

We would like to know how to capitalize select and input text field.

Answer


<!--from  w  w w. j a va2s  . com-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    $('select, input').css('text-transform', 'capitalize');
});
</script>
</head>
<body>
  <form>
    <select>
      <option>hello</option>
      <option>hello</option>
      <option>hello</option>
      <option>hello</option>
    </select> <input placeholder="Type here"></input>
  </form>
</body>
</html>

The code above is rendered as follows: