Thêm sự kiện Select Combobox Jquery

Thêm sự kiện Select Combobox Jquery

Cú pháp:

  $( "#ID_COM" ).change(function() {
   alert($("#ID_COM").val());
    });

Ví dụ 1:

     <select id="Select1">
        <option>A</option>
        <option>B</option>
    </select>
   
  <script>
    $( "#Select1" ).change(function() {
   alert($("#Select1").val());
    });
  </script>


Ví dụ 2:
<script>
function displayVals() {
var singleValues = $( "#single" ).val();
var multipleValues = $( "#multiple" ).val() || [];
// When using jQuery 3:
// var multipleValues = $( "#multiple" ).val();
$( "p" ).html( "<b>Single:</b> " + singleValues +
" <b>Multiple:</b> " + multipleValues.join( ", " ) );
}
 
$( "select" ).change( displayVals );
displayVals();
</script>

Thêm sự kiện Select Combobox Jquery