<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form action="#">
<input type="text"/>
<input type="password"/>
<input type="radio"/>
<input type="checkbox"/>
<input type="hidden"/>
<input type="file"/>
<input type="image"/>
<input type="submit"/>
<input type="reset"/>
<input type="button"/> <select name="sel" id="sel">
<option>ok</option>
</select>
<textarea name="ta" id="ta" cols="30" rows="4"></textarea> </form>
<button onclick="getform()">获取表单项</button> <hr/>
<br/><br/>
<div id="div2">
<input type="checkbox"/>吃饭
<input type="checkbox"/>睡觉
<input type="checkbox"/>打豆豆
</div>
<button onclick="chkall()">全选</button>
<button onclick="chkno()">全不选</button>
<button onclick="chkreverse()">反选</button> <script src="jquery-1.12.2.min.js"></script>
<script>
// 针对 checked属性的控制,不能使用常规attr函数,而应该换用prop函数 // jQuery也有循环写法,用each函数
// each操作中,每次获取的都是标准的DOM方式的元素而不是jQuery的对象
function chkreverse(){
$("#div2 :checkbox").each(function(i){
// this.checked = !this.checked;
$(this).prop('checked', !($(this).prop('checked')));
});
}
function chkno(){
$("#div2 :checkbox").prop('checked', false);
}
function chkall(){
// var div2 = document.getElementById('div2');
// var ins = div2.getElementsByTagName('input');
// for(var i=0; i<ins.length; i++){
// if(ins[i].type=='checkbox'){
// ins[i].checked = true;
// }
// } $("#div2 :checkbox").prop('checked', true); } function getform(){
// alert($(':input').length);
alert($(':button').length);
}
</script>
</body>
</html>

jquery表单的更多相关文章

  1. Jquery表单提交后获取返回Json值

    1.给form添加id值: <form action="/News/SaveMessage" method="post" accept-charset=& ...

  2. Jquery表单序列化和AJAX全局事件

    Jquery表单序列化 1.必须放在form标签内: 2.控件必须有name属性: 3.控件的value值会提交到服务器: 如: <form id="form1"> & ...

  3. 【jquery】Validform,一款不错的 jquery 表单验证插件

    关于 Validform 这是一款很不错的 jquery 表单验证插件,它几乎能够满足任何验证需求,仅仅一行代码就能搞定整站的表单验证. $('form').Validform(); 为什么能如此方便 ...

  4. 【jQuery基础学习】06 jQuery表单验证插件-Validation

    jQuery的基础部分前面都讲完了,那么就看插件了. 关于jQuery表单验证插件-Validation validation特点: 内置验证规则:拥有必填.数字.E-Mail.URL和信用卡号码等1 ...

  5. python_way day17 jQuery表单验证,事件绑定,插件,文本框架,正则表达式

    python_way day17 1.jQuery表单验证 dom事件绑定 jquery事件绑定 $.each return值的判断 jquery扩展方法 2.前段插件 3.jDango文本框架 4. ...

  6. jquery表单验证使用插件formValidator

    JQuery表单验证使用插件formValidator 作者: 字体:[增加 减小] 类型:转载 时间:2012-11-10我要评论 jquery表单验证使用插件formValidator,可供有需求 ...

  7. jQuery打造用户注册时获取焦点文本框出现提示jquery表单特效

    jQuery打造用户注册时获取焦点文本框出现提示效果的jquery表单特效 当获取焦点时,会分别的弹出相应的信息提示框,失去焦点就会隐藏提示信息. 效果兼容性很高,适用浏览器:IE6.IE7.IE8. ...

  8. jQuery 表单验证插件 jQuery Validation Engine 使用

    jQuery 表单验证插件 jQuery Validation Engine 使用方式如下: 1.引入头文件(注意一定要把jQuery放在前面),指定使用 jQuery Validation Engi ...

  9. jQuery表单验证以及将表单序列化为json对象小练习

    jquery表单验证(非实时验证),同时,将表单序列化为json对象提交表单. <!DOCTYPE html> <html lang="en"> <h ...

  10. JQuery 表单验证--jquery validation

    jquery validation,表单验证控件 官方地址 :http://jqueryvalidation.org/ jquery表单验证 默认值校验规则 jquery表单验证 默认的提示 < ...

随机推荐

  1. SpringBoot 精简笔记

    0. Fundamental a. @SpringBootApplication //启动类 b. pom.xml //Maven基本依赖 <parent> <groupId> ...

  2. c++读取list.txt中每行的字符串以及写入二进制文件

    #include <fstream> #include <fstream> string path = ""; FILE* fp = fopen(path. ...

  3. 采用MQTT协议实现android消息推送(1)MQTT 协议简介

    1.资料 mqtt官网 http://mqtt.org/ 服务端程序列表 https://github.com/mqtt/mqtt.github.io/wiki/servers 客户端库列表 http ...

  4. 常用维护SQL-数据清理

    truncate某个库的表数据 show full processlist; select concat('truncate table ',table_schema,'.',table_name,' ...

  5. element-ui多选框reserve-selection指定row-key保留数据更新之前的数据

    element-UI 的table表格数据有提供多项框的功能,只要在表格列中多加一列就可以选择表格的数据 但是有时候表格的数据是有分页的,分页一般是要重新请求后台数据,这样上一页也就是上一次请求的数据 ...

  6. 第二十一章:deploy and live updates

    通常我们开发一个app之后,需要把他们放到对应的应用商店上去以供下载.在此期间,需要经过应用商店的审核,包括初次上传和更新上传.短则需要数天,多则需要几个星期,这对于我们的快速产品迭代和hotfix来 ...

  7. WCF入门教程通信(二)

    一.概述 WCF能够建立一个跨平台的安全.可信赖.事务性的解决方案,是一个WebService,.Net Remoting,Enterprise Service,WSE,MSMQ的并集,有一副很经典的 ...

  8. 【Postman】Postman的安装和使用

    Postman一款非常流行的API调试工具.其实,开发人员用的更多.因为测试人员做接口测试会有更多选择,例如Jmeter.soapUI等.不过,对于开发过程中去调试接口,Postman确实足够的简单方 ...

  9. 分支结构case……end

    语法: case when 条件1 then 结果1 when 条件2 then 结果2 ……….. else 其它结果 end 执行顺序: 条件1成立执行结果1 条件2成立执行结果2 如果所有的wh ...

  10. Jquery实现自动生成二级目录

    在博客园开通博客以后,就看到某位博友写的js自动生成目录的文章,当时觉得生成目录能给阅读带来方便,所以就直接拿来使用了.用了一段时间以后,发现只能生成一级目录,不能生成多级目录,有点美中不足.所以想着 ...