Prev Demo
jQuery
>
Event.Target - Finding The Target Element
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> </head> <body> <div id="divEventTarget" style="background:#dedede;width:300px;height:100px;"> <br /> <p>event.target demo <br /> <span> this is span </span> <br />- This is the p </p> <br /> </div> <script> $("#divEventTarget").click(function (e) { alert(e.target.nodeName); }); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output