How jQuery Get Id of an HTML Element on Click

jQuery get id of an HTML elements using jQuery attr() method. You just need to put the id as an argument of the attr method.

If you want to learn more about the jQuery attr method syntax and other details, you have to visit jQuery get attr() method page.

jQuery Get id of div element

See the below given example to learn the method and get id.

Output


This is the answer to get id of an HTML element using jQuery attr() method.

The above example gives you the id of the HTML div element. Click the button given above to get the id in the alert part of the jquery.

If you to change the attribute value then see the jQuery set attr() method.

You must also read.