How to display the tag name of the clicked element using jQuery ? Last Updated : 29 Jan, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report Given a HTML document containing some elements and the task is to display the clicked element. Approach: First we create a HTML document containing some elements and add a jQuery function to display the clicked element. We select the HTML body using jQuery selector and when user click the element then get the element name and display the element name on the screen using text() method. Syntax: $("*", document.body).click(function (event) { event.stopPropagation(); var domElement = $(this).get(0); $("h3:first").text("Clicked Element: " + domElement.nodeName); }); Example: HTML <!DOCTYPE html> <html> <head> <script src= "//code.jquery.com/jquery-1.11.1.min.js"> </script> <meta charset="utf-8"> <title> How to display the tag name of the clicked element using jQuery? </title> <style> table, th, td { border: 1px solid black; } </style> </head> <body> <center> <h1 style="color: green;"> GeeksforGeeks </h1> <h2> How to display the tag name of the clicked element using jQuery? </h2> <table style="width:50%"> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> </tr> <tr> <td>Priya</td> <td>Sharma</td> <td>24</td> </tr> <tr> <td>Arun</td> <td>Singh</td> <td>32</td> </tr> <tr> <td>Sam</td> <td>Watson</td> <td>41</td> </tr> </table> <h3></h3> </center> <script> $("*", document.body).click(function (event) { event.stopPropagation(); var domElement = $(this).get(0); $("h3:first").text("Clicked Element: " + domElement.nodeName); }); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to display a message on dblclick event on all paragraphs of a page using jQuery ? V vkash8574 Follow Improve Article Tags : Web Technologies JQuery jQuery-Questions Similar Reads How to find the class of clicked element using jQuery ? In this article, we will find the class of the clicked element using jQuery. To find the class of clicked element, we use this.className property. The className property is used to set or return the value of an elementâs class attribute. Using this property, the user can change the class of an eleme 1 min read How to get the outer html of an element using jQuery ? Sometimes, there is a need to get the entire HTML element by its id and not merely its contents, for doing so, we shall use the HTML DOM outerHTML Property to get the outer HTML of HTML element. Syntax: document.getElementById("your-element-id").outerHTML) You can use a variable and initialize it to 2 min read How to display a message on dblclick event on all paragraphs of a page using jQuery ? The purpose of this article is to display a message to the double click event on all paragraphs on a page. Whenever you double-click on any of the paragraphs then the message will appear. Used method in jQuery: dblclick(): This method is used to trigger the dblclick event, or attaches a function to 1 min read How to get the object's name using jQuery ? In this article, we will learn how to find the name of an element using jQuery. The name attribute can be applied to multiple elements in HTML and is used to specify a name for any element. The name attribute of any element can be found out using the attr() method. This method is used to find the va 2 min read How to get the ID of the clicked button using JavaScript/jQuery ? To get the ID of a clicked button using JavaScript/jQuery means identifying which specific button was clicked within a webpage. This is useful when multiple buttons exist, and you need to distinguish between them based on their unique ID for further processing.So, to get the ID of the clicked button 3 min read How to get the ID of the clicked button using JavaScript/jQuery ? To get the ID of a clicked button using JavaScript/jQuery means identifying which specific button was clicked within a webpage. This is useful when multiple buttons exist, and you need to distinguish between them based on their unique ID for further processing.So, to get the ID of the clicked button 3 min read Like