jQuery--其他
来源:互联网 发布:js 给input value赋值 编辑:程序博客网 时间:2024/05/16 08:35
一、表单序列化
serialize() 将表单中所有选中项拼凑成一个字符串。类似get请求参数
例如:username=jack&password=1234&gender=man&....
serializeArray()将表单中所有选中项拼凑一个json数组
<script type="text/javascript">$(document).ready(function(){alert($("form").serialize());alert($("form").serializeArray());}); </script>
二、事件冒泡
event.stopPropagation()
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title><script type="text/javascript" src="../js/jquery-1.8.3.js"></script><script type="text/javascript">$(document).ready(function(){// 事件冒泡:子元素事件执行时,一并触发父元素相同的事件$("#outerDiv").click(function(){alert("outerDiv");});$("#innerDiv").click(function(event){alert("innerDiv");//方式1://return false;//方式2:通过event 提供函数event.stopPropagation();});});</script></head><body><div id="outerDiv" style="border:1px solid #f00;width:200px;height:200px"><div id="innerDiv" style="border:1px solid #00f;width:100px;height:100px"></div></div><br/><span id="showSpan"></span></body></html>
三、浏览器默认动作
event.preventDefault() ;
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title><script type="text/javascript" src="../js/jquery-1.8.3.js"></script><script type="text/javascript">$(document).ready(function(){// href a标签默认行为,阻止$("a").click(function(event){alert("谈谈谈");//方式1://return false;//方式2:event.preventDefault() ;});});</script></head><body><a href="http://www.itheima.com">你点我呀</a></body></html>
0 0
- jQuery--其他
- JQuery 其他选择器
- JQuery其他常用函数
- JQuery其他常用函数
- jQuery--9.其他常用
- (10)jQuery其他知识
- 13-Jquery其他效果下载
- JQuery 选择器 过滤器 其他 总结
- jQuery中获取其他DOM 节点
- 解决jquery和其他库的冲突
- jquery ajax 其他函数的运行关系
- jQuery和其他库的冲突
- Jquery给页面元素添加其他元素
- 解决jQuery和其他库的冲突
- 解决jQuery和其他库的冲突
- 4.1.8: jQuery事件之其他用法
- jquery和其他库发生冲突的解决办法
- jquery slibings选取同级其他元素
- AR 增强现实 开发入门详解 android studio Vuforia(二)更换背景目标图片
- tq210-kernel 3.0.8 SD卡作为文件系统
- Openwrt ubus机制的探究
- vim完美配置(偏c/c++)
- fastjson SerializerFeature序列化属性
- jQuery--其他
- fibonacci数列问题
- 新年新气象
- 晨魅--Js方法控制样式
- 用OpenSSL生成CA根证书来签名Keytool生成的证书请求
- i.MX Android R10.3 User Guide Update
- org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator
- 索引优化(一)
- 3.屏幕尺寸