Jquery 重置 input 和 select
/**
* 通用清除方法(清除input 和 select 的内容)
* jq 1.6以上attr() 改成 prop
*/
var resetAll = function(){
$("input[type='text']").prop("value","");
$('select').prop('selectedIndex', 0);
/*jQuery1.6以下版本*/
//$('select').attr('selectedIndex', 0);
};
本文介绍了一种使用JQuery重置表单的方法,适用于1.6及以上版本。该方法可以清空文本输入框和将下拉选择框重置到第一个选项。
3539

被折叠的 条评论
为什么被折叠?



