如何儲存和重現 jQuery 事件?


若要儲存和重現 jQuery 事件,請使用 控制檯 進行日誌記錄。

範例

你可以嘗試執行以下程式碼以瞭解如何儲存和重現 jQuery 事件

線上範例

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    window.events = []
    $("#track").click(function(event){
       window.events.push(event)
   
       $.each(window.events, function(i, item){
          console.log(i, item);
       });
   });
});
</script>
</head>
<body>

<a href="#" id="track">Track</a>

</body>
</html>

更新於: 2019 年 12 月 11 日

169 次瀏覽

開啟您的職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.