jquery 查找
来源:互联网 发布:网络经营项目 编辑:程序博客网 时间:2024/06/04 17:56
jquery 查找
$(document).ready(function() { $("#div > select").each(function(){ $(this).bind("change",function(){ $(this).nextAll("select").each(function(){ $(this).val(0);//select option:selected }); }); }); });
Html 代码
<input type="radio" name="sex" value="1" />男
<input type="radio" name="sex" value="2" />女
$("input[type=radio]:checked").val()
Html 代码
<select name="bank" id="bank">
<option value="icbc">工商银行</option>
<option value="ebank">光大银行</option>
<option value="bc">中国银行</option>
</select>
$("select option:selected").val() 如果有多个列表框 $("select[name=bank] option:selected").val()
跟上边类似 由于checkbox为数组,获取时只能获取 同名字的第一个值
Html 代码
<input type="checkbox" value="1" name="city"/> 北京
<input type="checkbox" value="2" name="city"/> 吉林
$("input[type=checkbox][name=city]:checked").val()//只能获取第一个所以要去循环$("input[type=checkbox][name=city]:checked").each(function(){ alert($(this).val());})
Html 代码
<table id="table1">
<tr id="tr1">
<td>a</td>
<td>b</td>
<td>c</td>
</tr>
<tr id="tr2">
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
$("#table1 tr[id=tr1] td:nth-child(3)").text()或者$("#table1 tr").each(function(){ alert($(this).children("td:eq(1)").text()); });
Html
$.ajax(function(){ url:"/reponse.jsp",// 请求连接 date:"age=m&id=001",//参数也可写到url后边 type:"post",//get 或 post dataType:"json",//返回 JSON 数据格式 xml 返回 XML 文档; text 返回纯文本字符串; html 返回纯文本 HTML 信息;包含 script 元素; script 返回纯文本 JavaScript 代码 success:function(returnValue){ alert(returnValue);}, //返回的数据 dataType用json时注意返回的格式正确,否则会执行faile方法 faile:function(){ //失败时的操作 }, async : true,//(默认: true) 默认设置下,所有请求均为异步请求。如果需要发送同步请求,请将此选项设置为 false。注意,同步请求将锁住浏览器,用户其它操作必须等待请求完成才可以执行。 timeout: 10000,//设置请求超时时间(毫秒) cache :true //设置为 false 将不会从浏览器缓存中加载请求信息 (默认: true)})
HTML代码
当用window.open()打开一个子页面时,在子页面获取父页面的值或改变值时:
父窗口:<input type="text" value="2010-1-1" id="date"/>
$("#date",window.opener.document).val()
输出结果为: 2010-1-1
HTML代码
<div>1</div><div>second</div><div>3</div><div>fourth</div><div>5</div><div>sixth</div>
var arr=$.makeArray($("div"));alert($(v[1]).text());
输出结果为: second
数组翻转 HTML代码
var arr=$.makeArray($("div"));var turnArr=arr.reverse();alert($(turnArr[1]).text());
输出结果为: 5
HTML代码
<div>1</div><div>second</div><div>3</div><div>fourth</div><div>5</div><div>sixth</div>
$("div").each(function(i){//一个参数 alert("第"+i+"个"+"内容是"+$(this).text());})
输出结果为: 第1个内容是1
第2个内容是second
第3个内容是3
...
对json格式输出 也可对数组迭代输出i为坐标号j为对应的值
$.each({name:"bingo",age:"25",sex:"youngMan"},function(i,j){ alert("key:"+i+",value"+j);})
输出结果为: name:name,value:bingo
name:age,value:25
name:sex,value:youngMan
- jquery 查找
- jquery查找某个children
- jquery查找元素
- Jquery 模糊配置查找
- jquery查找节点
- jquery中find查找
- jQuery 筛选查找
- jQuery 筛选查找
- jquery 元素查找
- jquery层级查找方式
- Jquery常用查找方法
- jquery查找元素
- jquery查找tr td
- jquery筛选--查找
- jquery查找各种节点
- jquery 查找DIV
- jQuery元素查找方法
- jquery查找子元素
- columnCheckTree1.1
- 学习记录
- EBMIDE——序
- 探秘google开源android项目gallery如何在手机内存有限的情况下缓存手机sdcard的图片或者视频
- Vim 的一些小技巧
- jquery 查找
- jquery validate
- PowerShell与cmd的对比点评(一)——文件定位和操作
- SVM系列
- db2 delete 大表不写日志方法
- 大数相乘-C语言实现
- SWL
- 事物的特性ACID
- 创建Oracle 的Data Guard 以及简单维护过程