這節(jié)不太懂
這節(jié)不太懂,馬克下別人的 再看看
? ? <script type="text/javascript">
? ? //點(diǎn)擊更新次數(shù)
? ? $("button:first").click(function(event,bottonName) {? ?//給第一個(gè)按鈕綁定一個(gè)click事件
? ? ? ? bottonName = bottonName || 'first';? ? ? ? ? ? //如果bottonName未定義就用參數(shù)first
? ? ? ? update($("span:first"),$("span:last"),bottonName);? //引用update函數(shù)
? ? });
? ? //通過(guò)自定義事件調(diào)用,更新次數(shù)
? ? $("button:last").click(function() {? ? //給第二個(gè)按鈕綁定click事件
? ? ? ? $("button:first").trigger('click','last');? ?//觸發(fā)第一個(gè)按鈕所綁定的click事件,并傳遞參數(shù)last
? ? });
? ? function update(first,last,bottonName) {? //自定義函數(shù)update
? ? ? ? first.text(bottonName);? ? ? ? //輸出文本bottonName參數(shù)的值(first或者last)
? ? ? ? var n = parseInt(last.text(), 10);? ? // 用n記錄點(diǎn)擊次數(shù)
? ? ? ? last.text(n + 1);? ? //輸出點(diǎn)擊次數(shù)
? ? }
? ? </script>
2019-10-01
??????字字字