2個(gè)疑問(wèn)??
? 1.
? ? ?
//點(diǎn)擊更新次數(shù)
? ? $("button:first").click(function(event,bottonName) {
? ? ? ? bottonName = bottonName || 'first';
? ? ? ? update($("span:first"),$("span:last"),bottonName);
? ? });
? ? //通過(guò)自定義事件調(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);
? ? }
$("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);
? ? });
為什么效果不對(duì)?
2016-08-20
1.這個(gè)last是他自己定義的參數(shù),對(duì)應(yīng)function中的(bottomName)。而update里的last,其實(shí)是 $("span:last");
2.去掉代碼之后,bottonNam 這個(gè)參數(shù)是空的。而且update函數(shù)都不存在了,怎么調(diào)用?
2016-08-31
感覺(jué)$("button:first").trigger('click','last'); 里面的last對(duì)應(yīng)的是? $("button:first").click(function(event,bottonName) 里面function的bottonName,不知道我說(shuō)的對(duì)不對(duì)
2016-08-20
trigger是觸發(fā)被選中元素指定的事件類(lèi)型
2016-08-20
看看一個(gè)trigger方法的定義