Prageeth Prageeth - 1 year ago 77
Javascript Question

Why select option change event can't have this and to get selected value?

In select option change event,why can't we get this or to get selected value instead of writing clumsy code like

$( "select option:selected" )
to get selected value ?

Answer Source

$("select").on('change', function(){
<script src=""></script>
  <option data-attribute="a">1</option>
  <option data-attribute="b">2</option>
  <option data-attribute="c">3</option>
  <option data-attribute="d">4</option>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download