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

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

這段代碼什么意思

?$("button:last").click(function() {

? ? ? ? $("button:first").trigger('click','last');

? ? });

這里面的last是什么?參數(shù)?怎么傳遞???還有下面那個(gè)bottonname是啥?

正在回答

6 回答

?//點(diǎn)擊更新次數(shù)

? ? $("button:first").click(function(event,bottonName) {

? ? ? ? bottonName = bottonName || 'first';

? ? ? ? update($("span:first"),$("span:last"),bottonName); ? ? ?//1號(hào)位

? ? });


? ? //通過自定義事件調(diào)用,更新次數(shù)

? ? $("button:last").click(function() {

? ? ? ? $("button:first").trigger('click','last');

? ? });


? ? function update(first,last,bottonName) { ? ? ? ? ? ? ? ? ? ? ? ? //2號(hào)位

? ? ? ? first.text(bottonName);

? ? ? ? var n = parseInt(last.text(), 10);

? ? ? ? last.text(n + 1);

? ? }

update很誤導(dǎo)人,1號(hào)位的update不是原生函數(shù),它所表示的實(shí)際上就是后文咱們自定義的2號(hào)位的update函數(shù)。

然后就可以清楚看到,三個(gè)參數(shù)是對(duì)應(yīng)的。1號(hào)位的update()是對(duì)后文2號(hào)位函數(shù)的主動(dòng)調(diào)用。而trigger()又會(huì)調(diào)用click函數(shù),所以無論點(diǎn)哪個(gè)按鈕,2號(hào)位函數(shù)都會(huì)起作用。

建議大家把update都改成別的名字再試試就懂了。一直覺得教程不該用這種“疑似原生函數(shù)名”,容易混淆,我們萌新經(jīng)常栽在這里。

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

我也看的暈的很,last怎么傳到里面的?

0 回復(fù) 有任何疑惑可以回復(fù)我~
?var?n?=?parseInt(last.text(),?10);?這段里面的10是干什么用的


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

慕粉3769385

以十進(jìn)制顯示
2016-08-15 回復(fù) 有任何疑惑可以回復(fù)我~

bottonName?=?bottonName?||?'first';?

所以上面這段話,可以怎么解釋呢

這篇看了有點(diǎn)懵懂阿~~~


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

zrning

我也不明白,同問~~~
2016-08-14 回復(fù) 有任何疑惑可以回復(fù)我~
#2

qq_加菲喵_0

buttonName = buttonName || 'first'; 第一個(gè)按鈕因?yàn)榍斑厸]有對(duì)buttonName的定義所以buttonName取得是'first'; 第二個(gè)按鈕因?yàn)閭魅隻uttonName參數(shù)傳入'last', 所以buttonName取得值'last';
2016-08-15 回復(fù) 有任何疑惑可以回復(fù)我~

借問,||這符號(hào)是什么意思啊

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

qq_夢(mèng)里_0 提問者

邏輯運(yùn)算符或。
2016-08-12 回復(fù) 有任何疑惑可以回復(fù)我~
????$("button:first").click(function(event,bottonName)?{
????????bottonName?=?bottonName?||?'first';
????????update($("span:first"),$("span:last"),bottonName);
????});

????//通過自定義事件調(diào)用,更新次數(shù)
????$("button:last").click(function()?{
????????$("button:first").trigger('click','last');
????});

????function?update(first,last,bottonName)?{
????????first.text(bottonName);
????????var?n?=?parseInt(last.text(),?10);
????????last.text(n?+?1);
????}

看課程評(píng)論里的這段解釋:重點(diǎn)在 $("button:first").trigger('click','last');直接引用了第一個(gè)按鈕的事件,'last'傳給 bottonName做參數(shù),所以點(diǎn)擊第二個(gè)按鈕,bottonName =“l(fā)ast”,接下來就是update()函數(shù)了,update(firstq,lastq,bottonName) ? 在第一個(gè)按鈕點(diǎn)擊事件時(shí)first,last,已經(jīng)傳入?yún)?shù)$("span:first"),$("span:last"),也就是顯示內(nèi)容的首位名稱和 第二位數(shù)字,接下來update()函數(shù)里面把first.text()根據(jù)點(diǎn)擊改括號(hào)里面內(nèi)容,last或first數(shù)字同理。


bottonName是下面定義的update函數(shù)的參數(shù)名

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

舉報(bào)

0/150
提交
取消

這段代碼什么意思

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

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

幫助反饋 APP下載

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

公眾號(hào)

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