如何使用jQuery重置选择元素 [英] How to reset a select element with jQuery

查看:98
本文介绍了如何使用jQuery重置选择元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有

<select id="baba">
<option>select something</option>
<option value="1">something 1</option>
<option value=2">something 2</option>
</select>

使用jQuery,重置select以便选择第一个选项的最简单(写得更少)的方法是什么?

Using jQuery, what would be the easiest (less to write) way to reset the select so the first option is selected?

推荐答案

尝试一下.这将起作用. $('#baba').prop('selectedIndex',0);

Try this. This will work. $('#baba').prop('selectedIndex',0);

在此处检查 http://jsfiddle.net/bibin_v/R4s3U/

这篇关于如何使用jQuery重置选择元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆