第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么最后一題a:first返回了a的3個內容?求詳細解答,多謝

這里 <div class="left first-div">
? ? ? ?<div class="div">
? ? ? ? ? ?<a>:first-child</a>
? ? ? ? ? ?<a>第二個元素</a>
? ? ? ? ? ?<a>:last-child</a>
? ? ? ?</div> ?
$(".left a:first").text(function(idnex,text){
? ? ? ? ? ?return '增加新的文本內容' + text
? ? ? ?})
這個為啥還會返回a(1),a(2)的內容???a:first不是代表a的第一個嗎?
結果如下:
增加新的文本內容:first-child
第二個元素
替換第一個a元素的內容
這里 <div class="left first-div">
? ? ? ?<div class="div">
? ? ? ? ? ?<a>:first-child</a>
? ? ? ? ? ?<a>第二個元素</a>
? ? ? ? ? ?<a>:last-child</a>
? ? ? ?</div> ?
$(".left a:first").text(function(idnex,text){
? ? ? ? ? ?return '增加新的文本內容' + text
? ? ? ?})
這個為啥還會返回a(1),a(2)的內容?。縜:first不是代表a的第一個嗎?
結果如下:
增加新的文本內容:first-child
第二個元素
替換第一個a元素的內容
這里 <div class="left first-div">
? ? ? ?<div class="div">
? ? ? ? ? ?<a>:first-child</a>
? ? ? ? ? ?<a>第二個元素</a>
? ? ? ? ? ?<a>:last-child</a>
? ? ? ?</div> ?
$(".left a:first").text(function(idnex,text){
? ? ? ? ? ?return '增加新的文本內容' + text
? ? ? ?})
這個為啥還會返回a(1),a(2)的內容?。縜:first不是代表a的第一個嗎?
結果如下:
增加新的文本內容:first-child
第二個元素
替換第一個a元素的內容

正在回答

1 回答

a:first確實是代表第一個a,你的誤區(qū)是三個a都顯示再一個div中,你把它們統(tǒng)一看成了第一個a的值,建議你給第一個加一個背景,這樣不管內容怎么變你就知道哪個才是第一個a的值:

<h3>.html()與.text()</h3>

? ? <div class="left first-div">

? ? ? ? <div class="div">

? ? ? ? ? ? <a class="firsta">:first-child</a>

? ? ? ? ? ? <a>第二個元素</a>

? ? ? ? ? ? <a>:last-child</a>

? ? ? ? </div> ?

? ? ? ? <div class="div">

? ? ? ? ? ? <a>:first-child</a>

? ? ? ? ? ? <a>第二個元素</a>

? ? ? ? ? ? <a>:last-child</a>

? ? ? ? </div>

? ? </div> ? ?

.firsta{ background-color: red;}不知道這樣解釋你明不明白

http://img1.sycdn.imooc.com//5a018dc50001d63e01740108.jpg

1 回復 有任何疑惑可以回復我~
#1

慕仙5237505 提問者

en ,有寫明白了貌似
2017-11-07 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

為什么最后一題a:first返回了a的3個內容?求詳細解答,多謝

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號