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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

測(cè)試二一定要這么寫嗎?

? ? <h4>測(cè)試二</h4>

? ? <div class="test2">

? ? ? ? <p>$('button:first').click(function(e) {alert(this)})</p>

? ? </div>

? ? <button>指定觸發(fā)事件</button>

? ? <script type="text/javascript">

? ? ? ? $('p').click(function(e) {

? ? ? ? ? ? alert(e.target.textContent)

? ? ? ? })

? ? ? ? //this指向button元素

? ? ? ? $("button:eq(1)").click(function() {

? ? ? ? ? ? $('p').click() //指定觸發(fā)綁定的事件

? ? ? ? })

? ? </script>


問題1:注釋里的“this”是指什么?為什么代碼里沒有this

問題2:不能把彈出p元素的內(nèi)容直接寫在$("button:eq(1)").click(funciton(){}的大括號(hào)嗎?

正在回答

2 回答

?$('p').click(function() {

? ? ? ? ? ? alert(this.textContent)

? ? ? ? })

一樣的。。。

0 回復(fù) 有任何疑惑可以回復(fù)我~

彈出p元素的內(nèi)容可以直接寫在大括號(hào)里,但這樣做的結(jié)果是你單獨(dú)點(diǎn)擊p的時(shí)候不會(huì)觸發(fā)事件,只有點(diǎn)擊按鈕才會(huì)彈出p元素的內(nèi)容。

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

測(cè)試二一定要這么寫嗎?

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)