Home >Web Front-end >JS Tutorial >The val() method in jquery reads from the last option forward_jquery

The val() method in jquery reads from the last option forward_jquery

WBOY
WBOYOriginal
2016-05-16 15:40:201129browse

In jquery, the val() method reads forward from the last option. If any of the value or text of the option matches, it will be selected

<select id="single">
  <option>选择1号</option>
  <option>选择2号</option>
  <option value="选择2号">选择3号</option>
</select>

  $("input:eq(0)").click(function(){
    $("#single").val("选择2号");
  });

So the 3rd option was finally chosen!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn