ITeye博客

js清空Form(基于jquery)

邪神Saber · 2014-05-29 14:27 · Markdown

// 清空form表单
function clearForm(form) {
	$(':input', form).each(function() {
		var type = this.type;
		var tag = this.tagName.toLowerCase();
		if (type == 'text' || type == 'password' || tag == 'textarea') {
			this.value = "";
		} else if (type == 'checkbox' || type == 'radio') {
			this.checked = false;
		} else if (tag == 'select') {
			this.selectedIndex = -1;
		}
	});
};

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。