Reputation: 429
the problem is this.
I have a select options, which works well on PC but not on Chrome browser on Android.
What can be wrong?
My HTML:
<select id='Button' class='' name='' onchange='' data-native-menu="true">
<option value="hello">Hello</option>
<option value="stack">Stack</option>
<option value="overflow">Overflow</option>
</select>
My jQuery:
$("#Button").on("click","option",function() {
var va = $(this).val();
alert(va);
});
My jsFiddle:
https://jsfiddle.net/h4g3cfrn/4/
Note: I do not need this in this case $("#Element").change(function() { // *** Anywhere
.
Upvotes: 1
Views: 690
Reputation: 3149
In plain and pure JavaScript you only need to define a function to deal with the onChange
event attribute of your <select>
tag.
1) edit your select tag to insert this: myFunction();
as your onchange event. Your final tag will look this way:
<select id='Button' class='' name='' onchange='myFunction();' data-native-menu="true">
2) define the following function to deal with the select changes:
<script>
function myFunction() {
var myVar = document.getElementById("Button").value;
alert(myVar);
}
</script>
If you want to try this before: https://jsfiddle.net/u3v5sj12/2/
Best.
Upvotes: 2