Handle select element change event
Description
The following code shows how to handle select element change event.
Example
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {<!-- w w w .j ava 2 s .c om-->
$("select").change(function() {
var str = "";
$("select option:selected").each(function() {
str += $(this).text() + " ";
});
$("div").text(str);
}).trigger('change');
});
</script>
</head>
<body>
<select name="garden" multiple="multiple">
<option>A</option>
<option selected="selected">B</option>
<option>C</option>
<option selected="selected">D</option>
<option>E</option>
<option>F</option>
</select>
<div></div>
</body>
</html>