用 jQuery 檢測 eventType 的方法是什麼?
要使用 jQuery 來檢測 eventType,請使用事件型別屬性。你可以嘗試執行以下程式碼,瞭解如何用 jQuery 來檢測 eventType −
示例
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").on("mouseover mouseout",function(event){ $("div").html("Event Type: " + event.type); }); }); </script> </head> <body> <div> <p>This has mouseover and mouseout event defined. Keep your cursor to see the event type below.</p> </div> </body> </html>
廣告