Bootstrap Tutorial - Style select element








The following code shows how to style select element.

Example

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-git2.js'></script>
<link rel="stylesheet" type="text/css"
  href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css">
<script type='text/javascript'
  src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
<script type='text/javascript'>
$(window).load(function(){<!--from  ww  w.ja v  a  2 s.  c om-->
    $('select').change(function(){
        $('input[type=name]').val($('option:selected',this).text());
        $('input[type=price]').val($(this).val());
    });
});
</script>
</head>
<body style='margin:30px'>
  <select>
    <option value="10">Apple</option>
    <option value="20">Orange</option>
  </select>
  <input type="name" />
  <input type="price" />
</body>
</html>

Click to view the demo