Show the difference between delegateTarget and currentTarget when delegation occurs
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>//from w w w. j ava 2 s . co m <script> $(document).ready(function(){ $("body").on("click", "button", function(event){ document.getElementById("demo").innerHTML = "delegateTarget returns: " + event.delegateTarget.nodeName + "<br/>currentTarget returns: " + event.currentTarget.nodeName; }); }); </script> </head> <body> <p id="demo"></p> <button>Test </button> </body> </html>