我如何使第一个选项的选择与jQuery?

<select id="target">
  <option value="1">...</option>
  <option value="2">...</option>
</select>

当前回答

Use:

$("#selectbox option:first").val()

请在这个JSFiddle中找到工作简单。

其他回答

如果你打算使用第一个选项作为默认的

<select>
    <option value="">Please select an option below</option>
    ...

然后你可以使用:

$('select').val('');

它很漂亮,也很简单。

你可以试试这个

$("#target").prop("selectedIndex", 0);

以下是我的做法:

$("#target option")
    .removeAttr('selected')
    .find(':first')     // You can also use .find('[value=MyVal]')
        .attr('selected','selected');

就像这样简单:

$('#target option:first').prop('selected', true);
$('#newType option:first').prop('selected', true);