xxxxxxxxxx
// Wait until the DOM is fully loaded
$(document).ready(function() {
// Bind a change event listener to the select element
$(document).on('change', 'select', function() {
// Handle the change event here
var selectedValue = $(this).val();
console.log('Selected value:', selectedValue);
});
});
xxxxxxxxxx
$('select').on('change', function() {
alert( this.value );
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select>
<option value="1">One</option>
<option value="2">Two</option>
</select>
xxxxxxxxxx
$(function(){
$("#status").change(function(){
var status = this.value;
alert(status);
if(status=="1")
$("#icon_class, #background_class").hide();// hide multiple sections
});
});
xxxxxxxxxx
// modify #inputId selector as per your code
$( "#inputId" ).change(function() {
alert( "Handler for .change() called." );
});
//OR
$("#InputId").on('change', function(){
alert( 'Handler for "change" called.' );
});
// OR
$("body").on('change', '#InputId', function(){
alert( 'Handler for "change" called.' );
});
xxxxxxxxxx
// Using jQuery, detect the change event on the select element
$('select').change(function() {
// Perform the desired action when an option is selected
// You can access the selected option using $(this).val()
var selectedOption = $(this).val();
// Code to execute when the option changes
// e.g., updating the page content, making an AJAX request, etc.
console.log("Selected option: " + selectedOption);
});
xxxxxxxxxx
$("select [name='element_name']").change(function(){
// condition goes here
});
xxxxxxxxxx
$(document).on('change', 'input', function() {
// Does some stuff and logs the event to the console
});
xxxxxxxxxx
$(document).ready(function(){
$("selector").chosen().change(function(){
var id = $(this).val();
});
})
xxxxxxxxxx
$("#mySelectElementID").val("my_new_value"); //change selected option/value with jQuery