This is an old question, but I am not sure why people didn't suggest using the event object to retrieve the info instead of searching through the DOM again. To learn more, see our tips on writing great answers. This is the simplest solution, at least for modern browsers. While working on some form-related user interface, we often use the select option, and to use that, we will surely need those values that are being selected. target property $("#ddlViewBy :selected").val() not without selected. if somebody also need to get the text of the option, here is it $ (this).find ('option:selected').text (); - Paul Iverson Cortez Nov 19, 2021 at 7:39 Add a comment 15 You can try this (using jQuery )- $ ('select').on ('change', function () { alert ( this.value ); }); I cannot use the above approach beacuse i am having multiple select boxes in that same page with whom i have to deal. and text. Thanks for contributing an answer to Stack Overflow! Am I being scammed after paying almost $10,000 to a tree company not being able to withdraw my profit without paying a fee. $('#SelectBoxId option:selected').text(); for getting the text as listed, $('#SelectBoxId').val(); for getting the selected index value. Is Hahn-Banach equivalent to the ultrafilter lemma in ZF. HTMLSelectElement.options The HTMLSelectElement.options read-only property returns a HTMLOptionsCollection of the <option> elements contained by the <select> element. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. The value -1 indicates that no element is selected. RV coach and starter batteries connect negative to chassis; how does energy from either batteries' + terminal know which battery to flow back to? Simpler - the guy above needs to write more code to make up for his initial vagueness. NOthing wrong with global var but using data is more concise. Using pure event element, without referencing DOM document is the most flexible way which works in many environments like React, Vue or just plain HTML forms. // reference to 'scripts' select list // used throughout the examples below var sel = document.getElementById('scripts'); // display value property of select list (from selected option) console.log( sel.value ); In it, you write code to get value. javascript select option innertext. Another approach wich can be handy in some situations, is passing the value of the selected directly to the function like this: You should also know that Javascript and jQuery are not identical. Updated my answer to support multiple boxes though. To the left, the drop-down, to the right, the easyui-searchbox: Mind: the var name is the '1' or '2', that is, the "value of the drop-down", while var value is the value that was entered in the easyui-searchbox instead and not relevant if you only want to know the value of the drop-down. Acceleration without force in rotational motion? I think my approach is causing a circular reference with a computed variable. How can I know which radio button is selected via jQuery? By attaching the change listener to the body, you can pretty much be sure this will fire after specific listeners for the selects, otherwise the value of 'data-previous' will be overwritten before you can even read it. If you order a special airline meal (e.g. All of the data required by the select elements is included within the Web page. You have to click somewhere to loose focus and another click on the dropdown. If the user explicitly confirms the change, for example, selecting a value from a selection dropdown with a mouse click. With jQuery, Change the div of select B when select A changes. }, Might be useful to people looking this up today if this wasn't default behavior 7 years ago, You set the onchange handler to some function or string. Launching the CI/CD and R Collectives and community editing features for How to get the children of the $(this) selector? function selectOption() { alert ("You have selected site "+ document.getElementById ("listSelect").value); } Set your value on some where hidden filed or local storage and get previous value from them. difference is that the onchange event also works on