Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
111
rated 0 times [  112] [ 1]  / answers: 1 / hits: 23181  / 6 Years ago, sun, july 15, 2018, 12:00:00

I added onclick event to my select tag like in the following code -



<option onclick=alert('Hello')>Say Hello</option>


but it does not work....



How can I set the option onclick event to fire ?


More From » onclick

 Answers
23

Try it in the onchange handler:





function checkAlert(evt) {
if (evt.target.value === Say Hello) {
alert('Hello');
}
}

<select onchange=checkAlert(event)>
<option>Test</option>
<option>Say Hello</option>
</select>




[#53978] Wednesday, July 11, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tobyl

Total Points: 598
Total Questions: 110
Total Answers: 114

Location: Vietnam
Member since Sat, Feb 12, 2022
2 Years ago
;