-5

I want to invoke a function when any option of select. Something like this:

$("option").click(() => {
  alert("hi")
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="selectID">
  <option>A</option>
  <option>B</option>
  <option>C</option>
</select>

But its not working somehow. Can anyone help.

Please Note

i dont want to capture change event , that doesnt trigger if i select already selected option

manish kumar
  • 4,037
  • 2
  • 32
  • 46

1 Answers1

0

This could help you

$("#selectID").on('change',() => {
  alert("hi")
 })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<select id="selectID">
   <option>A</option>
   <option>B</option>
   <option>C</option>
</select>
Akhil Aravind
  • 5,388
  • 15
  • 34