In jquery the val of method is read forward from the last option

  • 2020-08-22 21:34:52
  • OfStack

In jquery, the val() method is read forward from the last option and is selected if any one of the options value or text matches


<select id="single">
  <option> choose 1 No. </option>
  <option> choose 2 No. </option>
  <option value=" choose 2 No. "> choose 3 No. </option>
</select>

  $("input:eq(0)").click(function(){
    $("#single").val(" choose 2 No. ");
  });

So the third option is finally selected!


Related articles: