亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

2個疑問??

? 1.

? ? ?

//點擊更新次數

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

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

? ? ? ? update($("span:first"),$("span:last"),bottonName);

? ? });


? ? //通過自定義事件調用,更新次數

? ? $("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);

? ? }

$("button:first").trigger('click','last'); ?里面的'last'為什么是傳給?bottonName,而不是function update(first,last,bottonName)里的last?


2.去掉代碼

? ? ?

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

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

? ? ? ? update($("span:first"),$("span:last"),bottonName);

? ? });

為什么效果不對?

正在回答

4 回答

1.這個last是他自己定義的參數,對應function中的(bottomName)。而update里的last,其實是 $("span:last");
2.去掉代碼之后,bottonNam 這個參數是空的。而且update函數都不存在了,怎么調用?

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

清水3201892 提問者

非常感謝!
2016-08-20 回復 有任何疑惑可以回復我~

感覺$("button:first").trigger('click','last'); 里面的last對應的是? $("button:first").click(function(event,bottonName) 里面function的bottonName,不知道我說的對不對

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

trigger是觸發被選中元素指定的事件類型

0 回復 有任何疑惑可以回復我~

看看一個trigger方法的定義

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

2個疑問??

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

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號