jquery属性过滤器
2018-03-26 20:19
441 查看
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-3.3.1.js"></script>
<script>
$(function () {
$('#btn').click(function () {
//有id属性的div
//$('div[id]').css('backgroundColor', 'blue');
//获取有id属性的div并且id属性为dv1
//$('div[id=dv1]').css('backgroundColor', 'blue');
//$('input[name=name]').css('backgroundColor', 'blue');
//$('input[name!=name]').css('backgroundColor', 'blue');
//name属性必须以name开头的
//$('input[name^=name]').css('backgroundColor', 'blue');
//name属性必须以name结尾的
//$('input[name$=name]').css('backgroundColor', 'blue');
//name属性包含name的
//$('input[name*=name]').css('backgroundColor', 'blue');
//含有name和value属性的
$('input[name][value]').css('backgroundColor', 'blue');
});
})
</script>
<style>
div{
width:300px;
height:200px;
background-color:orange;
margin-bottom:20px;
}
</style>
</head>
<body>
<input type="button" name="name" value="显示效果" id="btn" />
<input type="text" name="1name1" value="" />
<input type="text" name="2name2" value="" />
<input type="text" name="name3" value="" />
<input type="text" name="name4" value="" />
<div id="dv1">
</div>
<div>
</div>
<div id="dv2">
</div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-3.3.1.js"></script>
<script>
$(function () {
$('#btn').click(function () {
//有id属性的div
//$('div[id]').css('backgroundColor', 'blue');
//获取有id属性的div并且id属性为dv1
//$('div[id=dv1]').css('backgroundColor', 'blue');
//$('input[name=name]').css('backgroundColor', 'blue');
//$('input[name!=name]').css('backgroundColor', 'blue');
//name属性必须以name开头的
//$('input[name^=name]').css('backgroundColor', 'blue');
//name属性必须以name结尾的
//$('input[name$=name]').css('backgroundColor', 'blue');
//name属性包含name的
//$('input[name*=name]').css('backgroundColor', 'blue');
//含有name和value属性的
$('input[name][value]').css('backgroundColor', 'blue');
});
})
</script>
<style>
div{
width:300px;
height:200px;
background-color:orange;
margin-bottom:20px;
}
</style>
</head>
<body>
<input type="button" name="name" value="显示效果" id="btn" />
<input type="text" name="1name1" value="" />
<input type="text" name="2name2" value="" />
<input type="text" name="name3" value="" />
<input type="text" name="name4" value="" />
<div id="dv1">
</div>
<div>
</div>
<div id="dv2">
</div>
</body>
</html>
相关文章推荐
- 关于我对 “关于jquery属性过滤器什么时候该加引号” 这帖子后的一些感悟
- jQuery表单对象属性过滤器
- jQuery表单对象属性过滤器
- jQuery编程基础精华02(属性、表单过滤器,元素的each,表单选择器,子元素过滤器(*),追加方法,节点,样式操作)
- jQuery之表单域属性过滤器
- jQuery编程基础精华02(属性、表单过滤器,元素的each,表单选择器,子元素过滤器(*),追加方法,节点,样式操作)
- JQuery属性过滤器不完整
- JQuery属性过滤器不完整
- jquery表单对象的属性过滤器
- jQuery编程基础精华(属性、表单过滤器,元素的each,表单选择器,子元素过滤器(*),追加方法,节点,样式操作)
- Jquery系列-Jquery属性过滤器
- jQuery表单域属性过滤器用法分析
- jquery学习之1.7-属性过滤器学习
- jquery表单对象属性过滤器
- jQuery属性过滤器
- jquery 属性过滤器
- jQuery表单域属性过滤器用法分析
- jQuery属性过滤器
- jquery中html、val与text三者属性取值的联系与区别介绍
- jQuery的属性