{"id":8532,"date":"2015-11-30T16:15:22","date_gmt":"2015-11-30T14:15:22","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=8532"},"modified":"2017-12-21T15:43:19","modified_gmt":"2017-12-21T13:43:19","slug":"jquery-get-id-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/","title":{"rendered":"jQuery get id example"},"content":{"rendered":"<p>The aim of this example is to show you how to get an element id using jQuery. The jQuery framework allows us to get an element id very easily.<\/p>\n<p>The element id must be unique in the HTML document. Getting it helps us in many situations like determining the pressed element or focused element in a page etc.<\/p>\n<p>The jQuery <code>attr()<\/code> function is used to get the element id. The function is used\u00a0in getting \/setting the element attributes by passing the attribute name. To get the element id we need to use this function as in <code>$(\"element\").attr(\"id\")<\/code> where this statement returns element&#8217;s id.<\/p>\n<p>Let&#8217;s look at some examples. To download the jQuery library click <a href=\"https:\/\/jquery.com\/download\/\" target=\"_blank\">here<\/a>.<br \/>\n[ulp id=&#8217;qGGDqWnle19VavkM&#8217;]<\/p>\n<h2>1. HTML<\/h2>\n<p>First of all you need to create a simple html document. The following HTML code contains only two buttons that we need to get their ids. <\/p>\n<pre class=\"brush:xml;highlight:[5,17,18]\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n\t&lt;title&gt;jQuery Get Id Example&lt;\/title&gt;\r\n\t&lt;script src=\"jquery-2.1.4.min.js\"&gt;&lt;\/script&gt;\r\n\t&lt;style type=\"text\/css\"&gt;\r\n\t\t.nicebutton {\r\n\t\t\t  color: #e0e0e0e;\r\n\t\t\t  font-size: 18px;\r\n\t\t\t  padding: 10px 20px 10px 20px;\r\n\t\t\t  text-decoration: none;\r\n\t\t}\r\n\t&lt;\/style&gt;\t\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;!-- HTML --&gt;\r\n&lt;button type=\"button\" id=\"button1\" class=\"nicebutton\"&gt;Button 1&lt;\/button&gt;\r\n&lt;button type=\"button\" id=\"button2\" class=\"nicebutton\"&gt;Button 2&lt;\/button&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h2>2.jQuery get id examples<\/h2>\n<h3>2.1 Show message according to pressed button<\/h3>\n<p>This example demonstrates how to get the pressed button id and show a message according to the pressed button. Method <code>$(this).attr(\"id\")<\/code> returns the id of the current object.<\/p>\n<pre class=\"brush:js;highlight:[5]\">&lt;!-- JAVASCRIPT --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$(document).ready(function(){\r\n   $(\"button\").click(function(){\r\n\t\tvar id=$(this).attr(\"id\");\r\n\t\tif(id==\"button1\"){\r\n\t\t\talert(\"Button 1 has been pressed\");\r\n\t\t} else if(id==\"button2\"){\r\n\t\t\talert(\"Button 2 has been pressed\");\r\n\t\t}\r\n    });\r\n});\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>The result in the browser would be:<br \/>\n<figure id=\"attachment_8529\" aria-describedby=\"caption-attachment-8529\" style=\"width: 800px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/11\/jquery_get_id_example1.gif\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/11\/jquery_get_id_example1.gif\" alt=\"jQuery get id,Show message according to pressed button\" width=\"800\" height=\"300\" class=\"size-full wp-image-8529\" \/><\/a><figcaption id=\"caption-attachment-8529\" class=\"wp-caption-text\">Show message according to pressed button example<\/figcaption><\/figure><\/p>\n<h3>2.2 Check if element has id attribute<\/h3>\n<p>If the element doesn&#8217;t have an id attribute, then the <code>attr()<\/code> method returns &#8220;undefined&#8221; as a result. For this reason we need to check the returned value before we use it like in the following example.<\/p>\n<p>Let&#8217;s create a new button without an id attribute:<\/p>\n<pre class=\"brush:xml\">&lt;button type=\"button\" class=\"nicebutton\"&gt;Button 3&lt;\/button&gt;\r\n<\/pre>\n<pre class=\"brush:js\">&lt;!-- JAVASCRIPT --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$(document).ready(function(){\r\n   $(\"button\").click(function(){\r\n\t\tvar id=$(this).attr(\"id\");\r\n\t\tif(id==undefined) {\r\n\t\t\talert(\"Element does not have id attribute\");\r\n\t\t}else {\r\n\t\t\tif(id==\"button1\"){\r\n\t\t\t\talert(\"Button 1 has been pressed\");\r\n\t\t\t} else if(id==\"button2\"){\r\n\t\t\t\talert(\"Button 2 has been pressed\");\r\n\t\t\t}\r\n\t }\r\n    });\r\n});\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>The result in the browser would be:<br \/>\n<figure id=\"attachment_8528\" aria-describedby=\"caption-attachment-8528\" style=\"width: 800px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/11\/jquery_get_id_example2.gif\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/11\/jquery_get_id_example2.gif\" alt=\"Check if element has id attribute example\" width=\"800\" height=\"300\" class=\"size-full wp-image-8528\" \/><\/a><figcaption id=\"caption-attachment-8528\" class=\"wp-caption-text\">Check if element has id attribute example<\/figcaption><\/figure><\/p>\n<h3>2.3 Get button1 id<\/h3>\n<p>Get element id by using it&#8217;s id as a selector is not a good idea because we already know it&#8217;s id, following example is useless and don&#8217;t try to use <code>attr()<\/code> method like this .<\/p>\n<pre class=\"brush:js;highlight:[4]\">&lt;!-- JAVASCRIPT --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$(document).ready(function(){\r\n    var id = $(\"#button1\").attr(\"id\");\r\n    ....\r\n});\r\n&lt;\/script&gt;\r\n<\/pre>\n<h2>3.jQuery attr() method example<\/h2>\n<p>As mentioned earlier, the jQuery <code>attr()<\/code> method is used for getting and setting an element&#8217;s other attributes, not only the element id. This example gets and changes the image source. Specifically, it gets the <code>scr<\/code> attribute like <code>$(\"#flowerImg\").attr(\"src\")<\/code> and then changes it to <code>$(\"#flowerImg\").attr(\"src\",\"flower2.jpg\")<\/code> <\/p>\n<p>Let&#8217;s add an image like the following:<\/p>\n<pre class=\"brush:xml\">&lt;img id=\"flowerImg\" src=\"flower1.jpg\" width=\"100\" height=\"100\" &gt;<\/pre>\n<pre class=\"brush:js;highlight:[5,7,9]\">&lt;!-- JAVASCRIPT --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$(document).ready(function(){\r\n   $(\"#button1\").click(function(){\r\n\t\tvar src = $(\"#flowerImg\").attr(\"src\");\r\n\t\tif(src==\"flower1.jpg\")\r\n\t\t\t$(\"#flowerImg\").attr(\"src\",\"flower2.jpg\");\r\n\t\telse \r\n\t\t\t$(\"#flowerImg\").attr(\"src\",\"flower1.jpg\");\r\n    });\r\n});\r\n&lt;\/script&gt; \r\n<\/pre>\n<p>The result in the browser would be:<br \/>\n<figure id=\"attachment_8554\" aria-describedby=\"caption-attachment-8554\" style=\"width: 800px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/11\/jquery_get_id_example3.gif\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/11\/jquery_get_id_example3.gif\" alt=\"jQuery attr() method example\" width=\"800\" height=\"300\" class=\"size-full wp-image-8554\" \/><\/a><figcaption id=\"caption-attachment-8554\" class=\"wp-caption-text\">jQuery attr method example<\/figcaption><\/figure><\/p>\n<h2>3.Conclusion<\/h2>\n<p>The element id is important and it must be unique in an HTML document. jQuery provides the <code>attr()<\/code> method to get the id. By using the <code>attr()<\/code> method we can also get and set other element attributes.<\/p>\n<h2>4. Download<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here : <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/11\/jquery-get-id-by-attr-method-example.zip\"><strong>jquery get id example<\/strong><\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The aim of this example is to show you how to get an element id using jQuery. The jQuery framework allows us to get an element id very easily. The element id must be unique in the HTML document. Getting it helps us in many situations like determining the pressed element or focused element in &hellip;<\/p>\n","protected":false},"author":106,"featured_media":919,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-8532","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>jQuery get id example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"The aim of this example is to show you how to get an element id using jQuery. The jQuery framework allows us to get an element id very easily. The element\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"jQuery get id example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"The aim of this example is to show you how to get an element id using jQuery. The jQuery framework allows us to get an element id very easily. The element\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2015-11-30T14:15:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-21T13:43:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Saeb Najim\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Saeb Najim\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/\"},\"author\":{\"name\":\"Saeb Najim\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/7554117e1066be33eda4c81bac192cc9\"},\"headline\":\"jQuery get id example\",\"datePublished\":\"2015-11-30T14:15:22+00:00\",\"dateModified\":\"2017-12-21T13:43:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/\"},\"wordCount\":448,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"articleSection\":[\"jQuery\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/\",\"name\":\"jQuery get id example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"datePublished\":\"2015-11-30T14:15:22+00:00\",\"dateModified\":\"2017-12-21T13:43:19+00:00\",\"description\":\"The aim of this example is to show you how to get an element id using jQuery. The jQuery framework allows us to get an element id very easily. The element\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"jQuery\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/jquery\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"jQuery get id example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/7554117e1066be33eda4c81bac192cc9\",\"name\":\"Saeb Najim\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1a6884eb32867720ef22a2a7728235120963a9a750d54d0356d5e3619ad3cd06?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1a6884eb32867720ef22a2a7728235120963a9a750d54d0356d5e3619ad3cd06?s=96&d=mm&r=g\",\"caption\":\"Saeb Najim\"},\"description\":\"Saeb has graduated from the University of Technology. During the last ten years (since 2005) he has been involved with a large number of projects about programming, software engineering, design and analysis . He works as a senior Software Engineer in the e-commerce and web development sector where he is mainly responsible for projects based on Java, Java frameworks, design patterns and Big Data technologies.\",\"sameAs\":[\"http:\/\/www.webcodegeeks.com\/\",\"https:\/\/www.linkedin.com\/in\/saebnajim\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/saeb-najim\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"jQuery get id example - Web Code Geeks - 2026","description":"The aim of this example is to show you how to get an element id using jQuery. The jQuery framework allows us to get an element id very easily. The element","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/","og_locale":"en_US","og_type":"article","og_title":"jQuery get id example - Web Code Geeks - 2026","og_description":"The aim of this example is to show you how to get an element id using jQuery. The jQuery framework allows us to get an element id very easily. The element","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2015-11-30T14:15:22+00:00","article_modified_time":"2017-12-21T13:43:19+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","type":"image\/jpeg"}],"author":"Saeb Najim","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Saeb Najim","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/"},"author":{"name":"Saeb Najim","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/7554117e1066be33eda4c81bac192cc9"},"headline":"jQuery get id example","datePublished":"2015-11-30T14:15:22+00:00","dateModified":"2017-12-21T13:43:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/"},"wordCount":448,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","articleSection":["jQuery"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/","name":"jQuery get id example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","datePublished":"2015-11-30T14:15:22+00:00","dateModified":"2017-12-21T13:43:19+00:00","description":"The aim of this example is to show you how to get an element id using jQuery. The jQuery framework allows us to get an element id very easily. The element","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-get-id-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"jQuery","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/jquery\/"},{"@type":"ListItem","position":4,"name":"jQuery get id example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/7554117e1066be33eda4c81bac192cc9","name":"Saeb Najim","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1a6884eb32867720ef22a2a7728235120963a9a750d54d0356d5e3619ad3cd06?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1a6884eb32867720ef22a2a7728235120963a9a750d54d0356d5e3619ad3cd06?s=96&d=mm&r=g","caption":"Saeb Najim"},"description":"Saeb has graduated from the University of Technology. During the last ten years (since 2005) he has been involved with a large number of projects about programming, software engineering, design and analysis . He works as a senior Software Engineer in the e-commerce and web development sector where he is mainly responsible for projects based on Java, Java frameworks, design patterns and Big Data technologies.","sameAs":["http:\/\/www.webcodegeeks.com\/","https:\/\/www.linkedin.com\/in\/saebnajim"],"url":"https:\/\/www.webcodegeeks.com\/author\/saeb-najim\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/8532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/106"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=8532"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/8532\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/919"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=8532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=8532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=8532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}