Monday, 22 February 2016

3 Examples to Get the Id of an Element in jQuery

As a page author, the id of an HTML element is something you should know, but there are scenarios when the page is automatically generated or may be some form elements are generated by using frameworks like JSF. In that case, what do you do if you want to find id attribute of some elements in the page programmatically? How do you find those ids using jQuery? There are several ways to solve this problem, a couple of them we'll see in this article itself. The jQuery API provides many methods to get any attribute or property including the id of an HTML element programmatically. In this article, I am going to share three easy ways to get the id of an element using jQuery.