{"id":1468,"date":"2022-08-30T15:16:47","date_gmt":"2022-08-30T15:16:47","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/19\/get-a-href-from-specific-table-cell-without-id-using-javascript-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:16:47","modified_gmt":"2022-08-30T15:16:47","slug":"get-a-href-from-specific-table-cell-without-id-using-javascript-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/get-a-href-from-specific-table-cell-without-id-using-javascript-collection-of-common-programming-errors\/","title":{"rendered":"Get a href from specific table cell without id using Javascript-Collection of common programming errors"},"content":{"rendered":"<p>Try this if you have &#8220;a&#8221; element inside the cell<\/p>\n<pre><code>document.getElementsByTagName(\"a\")[0].getAttribute(\"href\");\n<\/code><\/pre>\n<p>or if you want to set attribute<\/p>\n<pre><code>document.getElementsByTagName(\"a\")[0].setAttribute(\"href\", \"somelink.com\");\n<\/code><\/pre>\n<p>something like this might work..its hard to help cause you dont provide some code to know what you are trying to do<\/p>\n<pre><code>var links = document.querySelector(\"table tr td:last-child\");\n\nfor (var i = 0; i &lt; links.length; i++)\n{\n   links[i].setAttribute(\"href\", \"somelink.com\");\n}\n<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-19 13:18:47. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Try this if you have &#8220;a&#8221; element inside the cell document.getElementsByTagName(&#8220;a&#8221;)[0].getAttribute(&#8220;href&#8221;); or if you want to set attribute document.getElementsByTagName(&#8220;a&#8221;)[0].setAttribute(&#8220;href&#8221;, &#8220;somelink.com&#8221;); something like this might work..its hard to help cause you dont provide some code to know what you are trying to do var links = document.querySelector(&#8220;table tr td:last-child&#8221;); for (var i = 0; i &lt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1468","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1468","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1468"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1468\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}