分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

jQuery选择器基本选择器

发布时间:2023-09-06 01:52责任编辑:郭大石关键词:jQuery选择器
form input:查询form下所有input元素,含有后代关系
form>input:查询form下所有input元素,有有父子关系,没有后代关系
form+input:查询与form同级的第一个input元素,是兄弟关系
form~input:查询与form同级的所有input元素,是兄弟关系

<html> ?<head> ???<meta http-equiv="content-type" content="text/html; charset=UTF-8"> ???<script type="text/javascript" src="../js/jquery-1.6.js"></script> ?</head> ?<body> ???<form> ???????<input type="text" value="a"/> ?????????????<table> ???????????<tr> ???????????????<td> ???????????????????<input type="checkbox" value="b"/> ???????????????</td> ???????????</tr> ??????????????????</table> ???</form> ???<input type="radio" value="c"/> ???<input type="radio" value="d"/> ???<input type="radio" value="e"/> ???<script type="text/javascript"> ???????//1)找到表单form下所有的input元素的个数 ???????//alert($("form input").size()); ???????//2)找到表单form下所有的子级input元素个数 ???????//alert($("form>input").size()); ???????//3)找到表单form同级第一个input元素的value属性值 ???????//alert($("form+input").val()); ???????//4)找到所有与表单form同级的input元素个数 ???????alert($("form~input").size()); ???</script> ?</body></html>

jQuery选择器基本选择器

原文地址:http://blog.51cto.com/357712148/2113186

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved