How to get the object's name using jQuery ? Last Updated : 30 May, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 value of any attribute of the first element in the matched set. As we need to find the name of an element, we will use this method on the required element and pass "name" as the parameter in this method. Syntax: // Select the required element let selectedElem = $("elemToSelect"); // Get the name of the element // using the attr() method let elementName = selectedElem.attr('name'); console.log("The name of this element is:", elementName); The example below illustrates the above approach: Example: In this example, we will create a clone of the object using this method. HTML <!DOCTYPE html> <html> <head> <script src= "https://code.jquery.com/jquery-3.6.0.min.js"> </script> </head> <body> <h1 style="color: green;"> GeeksforGeeks </h1> <b> How to get the object's name using jQuery? </b> <form> <label for="name">Name:</label> <input type="text" id="name" name="fname" /> <br><br> <label for="age">Age:</label> <input type="number" id="age" name="age" /> <br><br> <label for="address">Address:</label> <textarea id="address" name="address"></textarea> </form> <script> // Select the required element let selectedElem = $("#name"); // Get the name of the element // using the attr() method console.log("The name of this element is:", selectedElem.attr('name')); let selectedElem2 = $("#age"); console.log("The name of this element is:", selectedElem2.attr('name')); let selectedElem3 = $("#address"); console.log("The name of this element is:", selectedElem3.attr('name')); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to select values from a JSON object using jQuery ? S sayantanm19 Follow Improve Article Tags : Web Technologies JQuery jQuery-Methods jQuery-Questions Similar Reads How to create clone of any object using jQuery ? In this article, we will learn to create a clone of an object using jQuery. This can be achieved using the extend() method of jQuery. The extend() method is used to merge the contents of multiple objects into the object passed as the first parameter. This can be used to clone an array as we can pass 3 min read How to select values from a JSON object using jQuery ? In this article, we will select values from a JSON object and display them on the browser using jQuery. To select values from a JSON object to webpage, we use append() method. This append() method in jQuery is used to insert some content at the end of the selected elements. Syntax: $(selector).appen 2 min read How to display the tag name of the clicked element using jQuery ? 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 th 1 min read How to get the first key name of a JavaScript object ? In JavaScript, accessing the first key name of an object involves identifying the initial property defined within that object. This concept is useful when you need to interact with or manipulate object properties in a specific order, particularly when the sequence of properties is relevant.Here we h 2 min read How to get the first key name of a JavaScript object ? In JavaScript, accessing the first key name of an object involves identifying the initial property defined within that object. This concept is useful when you need to interact with or manipulate object properties in a specific order, particularly when the sequence of properties is relevant.Here we h 2 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 Like