Today, We want to share with you get selected value of dropdown in javascript onchange.In this post we will show you javascript get selected option, hear for javascript select onchange get text we will give you demo and example for implement.In this post, we will learn about JQuery Get Dropdownlist Selected Value Onchange Event with an example.
How to get selected value of dropdown in JavaScript/jQuery on change?
using 1. jQuery Code
jQuery source code
$(document).ready(function() { $('select').change(function() { alert(this.value); }); });
HTML CODE
Example 2: jquery code
$(document).ready(function() { $('select').change(e => alert(e.target.value)); });
HTML code
Example 3: jquery code
$(document).ready(function() { $('select').on('change', function() { alert(this.value); }); });
HTML code
using 2. JavaScript
Example 1: HTML
javaScript Code
function getValue(option) { alert(option.value); }
Example 2: js code
document.getElementById('choice').onchange = function() { alert(this.value); }
HTML Code
I hope you get an idea about javascript select onchange get option text.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.