I met an error when i use chrome (it's ok in firefox). It's my code, very simple:
<html><head></head>
<body>
<select>
<option onclick="alert('abc');">A</option>
<option>B</option>
</select>
</body>
</html>
In firefox, when i click on option A, it will be show an alert('abc'). But in chrome, it doesn't run. Can i change something in setting of chrome?
Any suggestions?
Thanks!!!
use onchange event provided by html select,
<select onchange="alert(this.value)">
<option>A</option>
<option>B</option>
</select>
You need to use the onchange event
http://jsfiddle.net/WB3Q9/
When a user selects an option, the value of the select element changes, thus firing the onchange event and whatever function you binded to it
<select onchange="alert('The Value is ' + this.value)">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With