jquery选择器之属性过滤选择器
<style type="text/css">
/*高亮显示*/
.highlight{
background-color: gray
}
</style>
<body>
<div>
<p>Hello</p>
</div>
<div id="test">ID为test的DIV</div>
<input type="checkbox" id="s1" name="football" value="足球" />足球
<input type="checkbox" name="volleyball" value="排球" />排球
<input type="checkbox" id="s3" name="basketball" value="篮球" />篮球
<input type="checkbox" id="s4" name="other" value="其他" />其他
</body>
$("div[id]").addClass("highlight"); //查找所有含有ID属性的div元素
$("input[name='basketball']").attr("checked",true); //name属性值为basketball的input元素选中
$("input[name!='basketball']").attr("checked",true); //name属性值不为basketball的input元素选中
//此选择器等价于:not([attr=value])要匹配含有特定属性但不等于特定值的元素,请使用[attr]:not([attr=value])
$("input:not(input[name='basketball'])").attr("checked",true);
$("input[name^='foot']").attr("checked",true); //查找所有 name 以 'foot' 开始的 input 元素
$("input[name$='ball']").attr("checked",true); //查找所有 name 以 'ball' 结尾的 input 元素
$("input[name*='sket']").attr("checked",true); //查找所有 name 包含 'sket' 的 input 元素
$("input[id][name$='ball']").attr("checked",true); //找到所有含有 id属性,并且它的 name属性是以 ball结尾的
jquery选择器之属性过滤选择器的更多相关文章
- jquery选择器之属性过滤选择器详解
代码如下: <style type="text/css"> /*高亮显示*/ .highlight{ } </style> 复制代码代码如下 ...
- jQuery选择器之内容过滤选择器Demo
测试代码: 04-内容过滤选择器.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &q ...
- jQuery选择器之基本过滤选择器Demo
测试代码: 03-基本过滤选择器.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &q ...
- jQuery选择器之可见性过滤选择器Demo
测试代码 05-可见性过滤选择器.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &q ...
- jQuery选择器之属性筛选选择器
在这么多属性选择器中[attr="value"]和[attr*="value"]是最实用的 [attr="value"]能帮我们定位不同类型 ...
- jquery选择器之层级过滤选择器
$("ancestor descendant"):选取parent元素后所有的child元素 $("parent > child"):选取parent元素 ...
- jquery选择器之内容过滤选择器
先写出DOM元素的HTML结构: <style type="text/css"> /*高亮显示*/ .highlight{ background-color: gray ...
- jquery选择器之基本过滤选择器
<style type="text/css"> /*高亮显示*/ .highlight{ background-color: gray } </style> ...
- jQuery表单对象属性过滤选择器
jQuery表单对象属性过滤选择器 <div id="p1" attr="p1"> <input type="text" ...
随机推荐
- HDU 1102 Constructing Roads, Prim+优先队列
题目链接:HDU 1102 Constructing Roads Constructing Roads Problem Description There are N villages, which ...
- Windows平台配置Appium+Java环境
1) 安装JDK 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 安装 ...
- 基于jsoup的Java服务端http(s)代理程序-代理服务器Demo
亲爱的开发者朋友们,知道百度网址翻译么?他们为何能够翻译源网页呢,iframe可是不能跨域操作的哦,那么可以用代理实现.直接上代码: 本Demo基于MVC写的,灰常简单,copy过去,简单改改就可以用 ...
- JQ优化性能
一.注意定义jQuery变量的时候添加var关键字这个不仅仅是jQuery,所有javascript开发过程中,都需要注意,请一定不要定义成如下:$loading = $('#loading'); / ...
- 小言HTTP Authentication
什么是Authentication? 首先解释两个长的非常像.easy混淆的单词,Authentication(鉴定.认证)和Authorization(授权). Authentication就是要证 ...
- Windows 8.1 store app 开发笔记
原文:Windows 8.1 store app 开发笔记 零.简介 一切都要从博彦之星比赛说起.今年比赛的主题是使用Bing API(主要提到的有Bing Map API.Bing Translat ...
- Spring IOC之Bean 概述
1.Bean概述 一个Spring IOC容器管理一个或者多个bean.这些bean是根据你提供给容器的配置数据信息创建的,例如XML形式的的定义. 在容器内部,这些bean的定义表示为BeanDef ...
- 使用WCF订阅替换轮训
之前因为某些特定岗位的人不知道是不方便还是什么的原因,所以随便做了个独立于所有系统之外的邮件审批服务,功能是那些人在邮件里给待审批单据发个“同意”就自动审批通过,大致分为3部分:第一部分每隔固定时间去 ...
- Android项目--XML解析
对于xml文件,一般有两种解析方式: -----pull解析-------- -----Sax解析------- 如果xml文件是本地文件,那么就好说了 AssetManager assetManag ...
- Oracle中join left,join right,inner join,(+) 等
Oracle中join left,join right,inner join,(+) 等 博客分类: Oracle 建表create table TEST1create table TEST1( ...