认识熟悉jQuery选择器篇各个类容和功能,将老师最后一节表单选择器中的parent()关联问题解决

Original 2019-04-07 18:15:48 225
abstract:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>选择器</title><style type="text/css">div{width: 100px;height: 100px;margin: 10px;}<

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>选择器</title>

<style type="text/css">

div{width: 100px;height: 100px;margin: 10px;}

</style>

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

</head>

<body>

<div>jk</div>

<div>jun</div>

<div><span>jion</span></div>

<div>jjc</div>

<div></div>

<form action="">

输入框1<input type="text" name="name1"><br>

输入框2<input type="text" name="name2"><br>

输入框3<input type="password" name="name3" disabled="disabled"><br>

输入框4<input type="text" name="name4"><br>

<input type="button" name="name4" value="提交"><br>

<select>

<option>射手</option>

<option selected>魔蝎</option>

<option>白羊</option>

<option>狮子</option>


</select>


<label><input type="checkbox">看书</label>

<label><input type="checkbox">游泳</label>

<label><input type="checkbox" checked>游戏</label>

<label><input type="checkbox">看电影</label>

</form>


<script type="text/javascript">

$(function(){


$('div:contains(jjc)').css('background','red')

$('div:has(span)').css('background','blue')

$('div:empty').css('background','green')

$('div:parent').css('background','pink')


$('input[type]').css('background','blue')

$('input[type="button"]').css('background','red')

$('input[type="password"]').css('background','pink')

$('input[type!="password"]').css('background','green')

$('input[type^="p"]').css('background','black')

$('input[value$="交"]').css('background','yellow')

$('input[name*="2"]').css('background','yellow')

$('input[type="text"][name="name2"]').css('background','pink')

$(':selected').css('background','#ff90dd')

$(':checked').parent('label').css('color','#ff90dd')

})

</script>

</body>

</html>


Correcting teacher:天蓬老师Correction time:2019-04-08 09:35:40
Teacher's summary:选择jQuery, 主要就是看中了他的选择器, 这是他的精华, 也是他的亮点

Release Notes

Popular Entries