In this post, I will show you how to do it with and without JQuery.
The change() method triggers the change event, or attaches a function to run when a change event occurs.
However, you can also get this output in the alert message as per your requirement.
The change event occurs when the value of the element is changed. The second one is the text value of the select element. You will get the output in the div element using the jQuery html(). When we have the option value, so use the CSS Attribute selector, and .attr() $( ).find( ' option[value=""]' ).attr( ' selected' , ' selected' ) To fetch the index (position of the option in DOM tree) of an option by its value, use: