亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

jquery選擇器案例和總結(jié)

原創(chuàng) 2019-01-04 18:19:20 196
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml&quo

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>jquery表單選擇器</title>

<script type="text/javascript" src="jquery-3.3.1.min.js"  ></script>

</head>


<body>

<script>

$(function(){

//$(':enabled').css('background','pink')

//$(':disabled').css('background','red')

//$(':selected').css('color','red')

$(':checked').parent().css('color','red')

})

</script>


<form>

輸入框1:<input type="text" name=""><br>

輸入框2:<input type="text" name=""><br>

輸入框3:<input type="text" name="" disabled="disabled"><br>

輸入框4:<input type="text" name=""><br>


<select>

<option>雙魚座</option>

<option selected="selected">處女座</option>

<option>金牛座</option>

<option>射手座</option>

</select><br><br>

愛好:

<label><input type="checkbox" name="">看書</label>

<label><input type="checkbox" name="" checked="checked">游戲</label>

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


</form>


</body>

</html>


<!--總結(jié)

$('*')  選取所有元素

$('#id名')

$('.class名')

$('element') 根據(jù)給定的標(biāo)簽名匹配 如$('span')

$('#id名,.class,span') 匹配多個


$('父級 > 子級')


$(':first') 多個:  第一個元素

$(‘:last’)

比較

$(':gt(x)')

$(':lg(x)')

$(':eg(x)')


奇偶數(shù)

$('tr:odd'  選取奇數(shù)位置的 <tr> 元素

$('tr:even')選取偶數(shù)位置的 <tr> 元素

)


內(nèi)容選擇

$('contains(text)')

$(':parent') 匹配含有子元素或文本的子元素


表單

$('enabled')

$('disabled')

$('selected')

$('checked')

$(':checked').parent().css('color','red') 例子




 -->



批改老師:韋小寶批改時間:2019-01-05 09:12:14
老師總結(jié):寫的很不錯!jQuery中的選擇器是非常重要的!課后一定要多練習(xí)!

發(fā)布手記

熱門詞條