{"id":1013,"date":"2023-09-29T14:07:34","date_gmt":"2023-09-29T14:07:34","guid":{"rendered":"https:\/\/www.devopsfreelancer.com\/blog\/?p=1013"},"modified":"2023-09-30T14:08:17","modified_gmt":"2023-09-30T14:08:17","slug":"how-to-get-on-click-data-id-using-getattribute-method","status":"publish","type":"post","link":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/","title":{"rendered":"How to Get On click Data id using getAttribute() method ?"},"content":{"rendered":"\n<p>In this tutorial I&#8217;m going to learn how to get onclick get data id using JavaScript get  id of the element that has the onclick event.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>javascript code<\/strong><\/p>\n<\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n\tdata: null,\n\trender: function(data, type, row) {\n\t\t\treturn `\n\t&lt;div class=\"row\"&gt;\n\t\t&lt;div class=\"col-6\"&gt;\n\t\t\t&lt;button type=\"button\"\n\t\t\t\t\tclass=\"edits btn btn-primary\"\n\t\t\t\t\tdata-project-name=\"${data&#91;'project_name']}\"\n\t\t\t\t\tdata-id=\"${data&#91;'id']}\"&gt;\n\t\t\t\tStart Wizard\n\t\t\t&lt;\/button&gt;\n\t\t&lt;\/div&gt;\n\t&lt;\/div&gt;`;\n\t\t}\n\t\t,\n},<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"860\" height=\"351\" src=\"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-15.png\" alt=\"\" class=\"wp-image-1014\" srcset=\"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-15.png 860w, https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-15-300x122.png 300w, https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-15-768x313.png 768w\" sizes=\"auto, (max-width: 860px) 100vw, 860px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>$(document).on('click', '.edits', function() {\n                console.log('amit wizard click ho rha');\n                var projectName = $(this).data('project-name');\n                var projectId = $(this).data('id');\n                console.log('Project Name:', projectName);\n                console.log('Project ID:', projectId);\n                \/\/ Now you can use the projectName and projectId variables as needed\n                $('#get_project_name').val(projectName);\n                $('#exampleModal_getting').modal('show');\n            });\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial I&#8217;m going to learn how to get onclick get data id using JavaScript get id of the element that has the onclick event. javascript&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[388],"tags":[470,471,389,273],"class_list":["post-1013","post","type-post","status-publish","format-standard","hentry","category-jquery","tag-element-id","tag-get-id","tag-jquery","tag-laravel-jquery"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Get On click Data id using getAttribute() method ? - DevOps Freelancer<\/title>\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.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Get On click Data id using getAttribute() method ? - DevOps Freelancer\" \/>\n<meta property=\"og:description\" content=\"In this tutorial I&#8217;m going to learn how to get onclick get data id using JavaScript get id of the element that has the onclick event. javascript...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/\" \/>\n<meta property=\"og:site_name\" content=\"DevOps Freelancer\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/amitsthakurs\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-09-29T14:07:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-30T14:08:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-15.png\" \/>\n<meta name=\"author\" content=\"Amit Kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/amits_thakurs\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Amit Kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/\"},\"author\":{\"name\":\"Amit Kumar\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/#\\\/schema\\\/person\\\/22ed4bd82dc04200a2ca541b3e35fc5b\"},\"headline\":\"How to Get On click Data id using getAttribute() method ?\",\"datePublished\":\"2023-09-29T14:07:34+00:00\",\"dateModified\":\"2023-09-30T14:08:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/\"},\"wordCount\":39,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/image-15.png\",\"keywords\":[\"element-id\",\"get-id\",\"jQuery\",\"laravel-jquery\"],\"articleSection\":[\"jQuery\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/\",\"url\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/\",\"name\":\"How to Get On click Data id using getAttribute() method ? - DevOps Freelancer\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/image-15.png\",\"datePublished\":\"2023-09-29T14:07:34+00:00\",\"dateModified\":\"2023-09-30T14:08:17+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/#\\\/schema\\\/person\\\/22ed4bd82dc04200a2ca541b3e35fc5b\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/image-15.png\",\"contentUrl\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/09\\\/image-15.png\",\"width\":860,\"height\":351},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/how-to-get-on-click-data-id-using-getattribute-method\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Get On click Data id using getAttribute() method ?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/\",\"name\":\"DevOps Freelancer\",\"description\":\"We provide DevOps | SRE | DevSecOps | MLOps Freelancing\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/#\\\/schema\\\/person\\\/22ed4bd82dc04200a2ca541b3e35fc5b\",\"name\":\"Amit Kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d76fb4d0f15f7a458f1fd91063b44fbb7e7eb9e724b1c465d885054c2540250f?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d76fb4d0f15f7a458f1fd91063b44fbb7e7eb9e724b1c465d885054c2540250f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d76fb4d0f15f7a458f1fd91063b44fbb7e7eb9e724b1c465d885054c2540250f?s=96&d=mm&r=g\",\"caption\":\"Amit Kumar\"},\"description\":\"Hi I am Amit Kumar Thakur Experienced as s Software Developer with a demonstrated history of working in the information technology and services industry. Skilled in HTML, CSS, Bootstrap4, PHP, Laravel-9 , REST API,FB API,Google API, Youtube Api, Bitbucket,Github,Linux and jQuery. Strong engineering professional focused in Computer\\\/Information Technology Administration and Management. Currently my profile is to Software Developer, analyze the requirement, creating frame for web application, coding and maintenance.\",\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/amitsthakurs\\\/\",\"https:\\\/\\\/www.instagram.com\\\/amits_thakurs\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/amits-thakurs\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/amits_thakurs\"],\"url\":\"https:\\\/\\\/www.devopsfreelancer.com\\\/blog\\\/author\\\/amit\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Get On click Data id using getAttribute() method ? - DevOps Freelancer","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.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/","og_locale":"en_US","og_type":"article","og_title":"How to Get On click Data id using getAttribute() method ? - DevOps Freelancer","og_description":"In this tutorial I&#8217;m going to learn how to get onclick get data id using JavaScript get id of the element that has the onclick event. javascript...","og_url":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/","og_site_name":"DevOps Freelancer","article_author":"https:\/\/www.facebook.com\/amitsthakurs\/","article_published_time":"2023-09-29T14:07:34+00:00","article_modified_time":"2023-09-30T14:08:17+00:00","og_image":[{"url":"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-15.png","type":"","width":"","height":""}],"author":"Amit Kumar","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/amits_thakurs","twitter_misc":{"Written by":"Amit Kumar","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/#article","isPartOf":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/"},"author":{"name":"Amit Kumar","@id":"https:\/\/www.devopsfreelancer.com\/blog\/#\/schema\/person\/22ed4bd82dc04200a2ca541b3e35fc5b"},"headline":"How to Get On click Data id using getAttribute() method ?","datePublished":"2023-09-29T14:07:34+00:00","dateModified":"2023-09-30T14:08:17+00:00","mainEntityOfPage":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/"},"wordCount":39,"commentCount":0,"image":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-15.png","keywords":["element-id","get-id","jQuery","laravel-jquery"],"articleSection":["jQuery"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/","url":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/","name":"How to Get On click Data id using getAttribute() method ? - DevOps Freelancer","isPartOf":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/#primaryimage"},"image":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/#primaryimage"},"thumbnailUrl":"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-15.png","datePublished":"2023-09-29T14:07:34+00:00","dateModified":"2023-09-30T14:08:17+00:00","author":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/#\/schema\/person\/22ed4bd82dc04200a2ca541b3e35fc5b"},"breadcrumb":{"@id":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/#primaryimage","url":"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-15.png","contentUrl":"https:\/\/www.devopsfreelancer.com\/blog\/wp-content\/uploads\/2023\/09\/image-15.png","width":860,"height":351},{"@type":"BreadcrumbList","@id":"https:\/\/www.devopsfreelancer.com\/blog\/how-to-get-on-click-data-id-using-getattribute-method\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.devopsfreelancer.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Get On click Data id using getAttribute() method ?"}]},{"@type":"WebSite","@id":"https:\/\/www.devopsfreelancer.com\/blog\/#website","url":"https:\/\/www.devopsfreelancer.com\/blog\/","name":"DevOps Freelancer","description":"We provide DevOps | SRE | DevSecOps | MLOps Freelancing","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.devopsfreelancer.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.devopsfreelancer.com\/blog\/#\/schema\/person\/22ed4bd82dc04200a2ca541b3e35fc5b","name":"Amit Kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d76fb4d0f15f7a458f1fd91063b44fbb7e7eb9e724b1c465d885054c2540250f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d76fb4d0f15f7a458f1fd91063b44fbb7e7eb9e724b1c465d885054c2540250f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d76fb4d0f15f7a458f1fd91063b44fbb7e7eb9e724b1c465d885054c2540250f?s=96&d=mm&r=g","caption":"Amit Kumar"},"description":"Hi I am Amit Kumar Thakur Experienced as s Software Developer with a demonstrated history of working in the information technology and services industry. Skilled in HTML, CSS, Bootstrap4, PHP, Laravel-9 , REST API,FB API,Google API, Youtube Api, Bitbucket,Github,Linux and jQuery. Strong engineering professional focused in Computer\/Information Technology Administration and Management. Currently my profile is to Software Developer, analyze the requirement, creating frame for web application, coding and maintenance.","sameAs":["https:\/\/www.facebook.com\/amitsthakurs\/","https:\/\/www.instagram.com\/amits_thakurs\/","https:\/\/www.linkedin.com\/in\/amits-thakurs\/","https:\/\/x.com\/https:\/\/twitter.com\/amits_thakurs"],"url":"https:\/\/www.devopsfreelancer.com\/blog\/author\/amit\/"}]}},"_links":{"self":[{"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/posts\/1013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/comments?post=1013"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/posts\/1013\/revisions"}],"predecessor-version":[{"id":1124,"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/posts\/1013\/revisions\/1124"}],"wp:attachment":[{"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/media?parent=1013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/categories?post=1013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsfreelancer.com\/blog\/wp-json\/wp\/v2\/tags?post=1013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}