課程
/前端開發(fā)
/jQuery
/jQuery基礎(chǔ) (一)—樣式篇
這個(gè)到底選擇的誰 ,,選擇的是a元素的第一個(gè)子元素??還是所有a元素的父級(jí)元素的第一個(gè)子元素
2016-09-12
源自:jQuery基礎(chǔ) (一)—樣式篇 2-11
正在回答
這個(gè)就很好理解了
$(".first-div a:first-child").css("color", "#CD00CD");
.first-div 指定class名為.first-div 的標(biāo)簽元素
a:first-child 指定a標(biāo)簽的父元素的子標(biāo)簽中的第一個(gè)標(biāo)簽
舉例如下:
? ? ? ? <div class="first-div">
? ? ? ? ? ? <a>:first-child</a>
? ? ? ? ? ? <a>第二個(gè)元素</a>
? ? ? ? ? ? <a>:last-child</a>
? ? ? ? </div>
? ? ? ? ?<div class="first-div">
? ? ? ? <div class="firstdiv">
? ? ?.first-div 指定class名為.first-div 的標(biāo)簽元素 ----即指定 ?? ? ? <div class="first-div">??</div>標(biāo)簽
a:first-child ?指:將會(huì)選中 父標(biāo)簽(? <div class="first-div">??</div>標(biāo)簽)下的所有子標(biāo)簽 里邊的第一個(gè)標(biāo)簽
最后結(jié)果就是 ? 選中了帶下劃線的那些 ?標(biāo)簽(都是第一個(gè))
小菜鳥飛 提問者
Airly 回復(fù) 小菜鳥飛 提問者
肖炎
選個(gè)class=.first_div元素中,所有a標(biāo)簽的第一個(gè)子元素
選擇的是class選擇器下 a元素下的第一個(gè)子元素
舉報(bào)
jQuery初入開啟樣式修煉,體驗(yàn)萬能的jQuery樣式集搭建網(wǎng)站布局
1 回答$(".first-div a:first-child").css("color", "#CD00CD");?
6 回答查找class="first-div"下的第一個(gè)a元素 為什么是$(".first-div a:first-child").css("color", "#CD00CD"); 為什么是$(".first-div:first-child").css("color", "#CD00CD");他的第一個(gè)子元素就是a元素啊
1 回答$('.last-div a:nth-child(2)').css("color", "#CD00CD");
1 回答為什么寫$(".first-div a:first-child")查找才有反應(yīng),而寫$("a:first-child.first-div ")不行??
1 回答$(".div:contains(':contains')").css("color", "#CD00CD");
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-10-17
這個(gè)就很好理解了
2016-09-18
$(".first-div a:first-child").css("color", "#CD00CD");
.first-div 指定class名為.first-div 的標(biāo)簽元素
a:first-child 指定a標(biāo)簽的父元素的子標(biāo)簽中的第一個(gè)標(biāo)簽
舉例如下:
? ? ? ? <div class="first-div">
? ? ? ? ? ? <a>:first-child</a>
? ? ? ? ? ? <a>第二個(gè)元素</a>
? ? ? ? ? ? <a>:last-child</a>
? ? ? ? </div>
? ? ? ? ?<div class="first-div">
? ? ? ? ? ? <a>:first-child</a>
? ? ? ? </div>
? ? ? ? <div class="firstdiv">
? ? ? ? ? ? <a>:first-child</a>
? ? ? ? ? ? <a>第二個(gè)元素</a>
? ? ? ? ? ? <a>:last-child</a>
? ? ? ? </div>
? ? ?.first-div 指定class名為.first-div 的標(biāo)簽元素 ----即指定 ?? ? ? <div class="first-div">??</div>標(biāo)簽
a:first-child ?指:將會(huì)選中 父標(biāo)簽(? <div class="first-div">??</div>標(biāo)簽)下的所有子標(biāo)簽 里邊的第一個(gè)標(biāo)簽
最后結(jié)果就是 ? 選中了帶下劃線的那些 ?標(biāo)簽(都是第一個(gè))
2016-09-12
選個(gè)class=.first_div元素中,所有a標(biāo)簽的第一個(gè)子元素
2016-09-12
選擇的是class選擇器下 a元素下的第一個(gè)子元素