如何儲存和再現 jQuery 事件?


要儲存和再現 jQuery 事件,請使用console 進行記錄。

示例

你可以嘗試執行以下程式碼來了解如何儲存和再現 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>

更新於:11-12-2019

169 次瀏覽

開啟您的職業

完成課程透過認證

開始
廣告