{"id":607,"date":"2006-07-29T14:15:00","date_gmt":"2006-07-29T11:15:00","guid":{"rendered":"http:\/\/www.mummila.net\/nuudelisoppa\/index.php\/?p=607"},"modified":"2006-07-29T14:15:00","modified_gmt":"2006-07-29T11:15:00","slug":"how-to-change-an-img-elements-alt-text-using-javascript","status":"publish","type":"post","link":"https:\/\/mummila.net\/nuudelisoppa\/2006\/07\/29\/how-to-change-an-img-elements-alt-text-using-javascript\/","title":{"rendered":"How to change an img element&#39;s alt text using JavaScript"},"content":{"rendered":"<blockquote><p>&#8220;<tt>setAttribute<\/tt> has two arguments: the attribute name and the attribute value. You can set any attribute of any element using the <tt>setAttribute<\/tt> method.&#8221;<\/p>\n<p><a href=\"http:\/\/developer.mozilla.org\/en\/docs\/Traversing_an_HTML_table_with_JavaScript_and_DOM_Interfaces#Creating_element_nodes_and_inserting_them_into_the_document_tree\">Mozilla<\/a><\/p><\/blockquote>\n<p><tt>alt<\/tt> is a property of the <a href=\"http:\/\/www.w3schools.com\/htmldom\/dom_obj_image.asp\">image element<\/a>, so the JavaScript code for changing an img&#8217;s alt text becomes:<\/p>\n<p><code>myimg.setAttribute('alt', \"New alt text\");<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;setAttribute has two arguments: the attribute name and the attribute value. You can set any attribute of any element using the setAttribute method.&#8221; Mozilla alt is a property of the image element, so the JavaScript code for changing an img&#8217;s alt text becomes: myimg.setAttribute(&#8216;alt&#8217;, &#8220;New alt text&#8221;);<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-607","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/607","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/comments?post=607"}],"version-history":[{"count":0,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/607\/revisions"}],"wp:attachment":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/media?parent=607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/categories?post=607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/tags?post=607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}