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