jQuery Form How to - Handle click event for select element








Question

We would like to know how to handle click event for select element.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.4.4.min.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--from  w ww .ja  v  a2  s  . c om-->
    $('.select').click(function() {
        console.log("!!!!!!!")
    });
});
</script>
</head>
<body>
<html>
<head></head>
<body>
  <select class="select" style="max-width: 400px">
    <option>A</option>
    <option>B</option>
    <option>C</option>
    <option>D</option>
    <option>E</option>
    <option>F</option>
  </select>
</body>
</html>
</body>
</html>

The code above is rendered as follows: