How to use JQuery Event target Property
This article describe about jQuery Event target Property.
jQuery Event target Property
Which DOM (document object model) element triggered the event it is specified by the target property.
Syntax
Property |
Description |
event |
Required. Define the event to check. That event parameter comes from bind method. |
Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("p, button, h1, h2").click(function (event) {
$("div").html("Triggered by a " + event.target.nodeName + " element.");
});
});
</script>
</head>
<body>
<h1>This is a first heading</h1>
<h2>This is a second heading</h2>
<p>This is my first paragraph</p>
<button>This is first button</button>
<p>If headings, paragraphs and button element has a click.<br />And if you trigger one of the events, the div below will tell you which element triggered the event.</p>
<div />
</body>
</html>
|
Output
Note: In the above output you click on the button then output become
You may also want to read these related articles Click here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here