<!DOCTYPE html>
<
html
>
<
head
>
<
script
src
=
</
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
>