select option trigger in js 1

select option trigger in js

/*html*/


/*Function js*/
var select = document.querySelector('#sel'),
    input = document.querySelector('input[type="button"]');
select.addEventListener('change',function(){
    alert('Yare yare daze');
});

/*RESULT*/
/*When change value trigger alert('Yare yare daze') */



Here is what the above code is Doing:
1. We select the select element and assign it to a variable called select.
2. We select the input element and assign it to a variable called input.
3. We add an event listener to the select element that listens for the change event.
4. When the change event is triggered, we alert the user.

The change event is triggered when the value of an element has been changed.

The change event is often used in combination with validation of input fields.

The change event is not often used with buttons.

The change event is often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with elements.

The change event is not often used with