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