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
Release: 2016-05-16 15:40:20
Original
1119 people have browsed it

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号");
  });
Copy after login

So the 3rd option was finally chosen!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template