一、基本知识
<body>
<ul>
<li class="li">muzi</li>
<li class="li"><strong>digbig</strong></li>
<li class="li">muzidigbig</li>
</ul>
</body>
<script src="./js/jquery-3.3.1.min.js"></script>
<script>
$(function(){
//判断ul的孩子中是否有'.li'的元素
var bool = $('.li:first').parent('ul').children().is('.li');
console.log(bool);//true
//判断li中是否有strong这个标签 然后将这个字体变为hotpink
if($('.li').children().is('strong')){
$('.li').children().css('color','hotpink')
}
})
</script>
二、is()函数一些比较常见的用法
// 是否是隐藏的
$('#test').is(':visible');
$('#test').is(':hide')
// 判断input元素是否被选中
$('input[name=chkNoChecked]').is(':checked');
// 是否是第一个子元素
$(this).is(":first-child");
// 是否包含.blue,.red的class
$(this).is(".blue,.red");
// 文本中是否包含Peter这个词
$(this).is(":contains('Peter')");