jQuery插件之清空区域内容
来源:互联网 发布:mac php ext 目录 编辑:程序博客网 时间:2024/04/28 07:17
(function($) {
$.fn.extend({
clear:function(){
cl(this);
},
}) ;
function cl(_id){
$("input,select,textarea", _id).each(function() {
var t = this.type, tag = this.tagName.toLowerCase();
if (t == "text" || t == "hidden" || t == "password"
|| tag == "textarea") {
this.value = "";
} else {
if (t == "file") {
var _1e = $(this);
_1e.after(_1e.clone().val(""));
_1e.remove();
} else {
if (t == "checkbox" || t == "radio") {
this.checked = false;
} else {
if (tag == "select") {
this.selectedIndex = -1;
}
}
}
}
});
};
})(jQuery);
$(function(){
$("#btn").click(function(){
$("#addForm").clear();
});
});
=====================
(function ($) {
$.fn.extend({
clear: function () {
cl(this);
},
validate: function (messages) {
$("input,select,textarea", this).each(function () {
var t = this.type, tag = this.tagName.toLowerCase();
if (t == "text" || t == "password" || tag == "textarea") {
if (this.value == "") {
$(this).addClass("on");
}
} else {
if (t == "file") {
} else {
if (t == "checkbox" || t == "radio") {
} else {
if (tag == "select" && this.selectedIndex == -1) {
$(this).addClass("on");
}
}
}
}
});
}
});
function cl(_id) {
$("input,select,textarea", _id).each(function () {
var t = this.type, tag = this.tagName.toLowerCase();
if (t == "text" || t == "hidden" || t == "password" || tag == "textarea") {
this.value = "";
} else {
if (t == "file") {
var _1e = $(this);
_1e.after(_1e.clone().val(""));
_1e.remove();
} else {
if (t == "checkbox" || t == "radio") {
this.checked = false;
} else {
if (tag == "select") {
this.selectedIndex = -1;
}
}
}
}
});
};
})(jQuery);
$(function () {
$("#btn").click(function () {
var res = $("#form1").validate({ "username": "用户名称不能为空" });
});
$("#cle").click(function () {
var res = $("#form1").clear();
});
});
- jQuery插件之清空区域内容
- JQuery清空节点内容
- jquery form内容清空
- Jquery清空div内容
- jquery清空元素内容
- jquery 清空file里的内容
- Panel内容清空
- 清空iframe内容
- 清空FileUpload内容
- 清空fck内容
- 清空剪切板内容
- 清空CEdit内容
- 清空EditText内容
- 清空canvas内容
- 清空文本框内容
- 用JQUERY实现清空所有文本框的内容
- js或者jquery清空文本框所有内容
- jquery如何清空<input type="file"/>的内容
- 读jQuery之五(取DOM元素)
- XFire完整入门教程
- struts2的json-default和struts-default的区别
- jsp exception对象获取异常信息
- python 时间
- jQuery插件之清空区域内容
- 读jQuery之六(缓存数据)
- 读jQuery之七(判断点击了鼠标哪个键)
- 读jQuery之八(包装事件对象)
- 读jQuery之十(事件模块概述)
- 用C语言实现Ping程序功能
- 递归json字符串
- itext经验总结( 转)
- Openstack部署工具总结