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.


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.


Get FREE Access to Toolkit and Resources that we are using in Tutorialdeep that Every Professional Should Have! in one handy PDF.

Get the PDF

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Download Link Will be Send to Your Email id