<h2>自定義事件trigger</h2>? ? <div class="left">? ? ? ? <div><span></span><span>0</span>點擊次數</div>? ? ? ? <button>直接點擊</button>? ? ? ? <button>通過自定義點擊</button>? ? </div>? ? <script type="text/javascript">? ? //點擊更新次數? ? $("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);? ? }? ? </script>
- 3 回答
- 0 關注
- 2025 瀏覽
添加回答
舉報
0/150
提交
取消