{"id":926,"date":"2013-01-24T19:31:03","date_gmt":"2013-01-24T19:31:03","guid":{"rendered":"https:\/\/ibex.tech\/javascript\/?p=926"},"modified":"2024-01-30T13:23:17","modified_gmt":"2024-01-30T13:23:17","slug":"changing-images-in-javascript","status":"publish","type":"post","link":"https:\/\/ibex.tech\/javascript\/images\/changing-images-in-javascript","title":{"rendered":"Changing Images In Javascript"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Changing an image src<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;img id=\"my_image\" src=\"images\/image1.png\" width=\"22\" height=\"8\"&gt;\n\n&lt;script&gt;\n\/\/Chage the image source:\ndocument.getElementById(\"my_image\").src=\"images\/image2.png\";\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Using jQuery to change an image src<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/We're using some variables just to demonstrate how they can get used sucessfully\n  let my_image_id_value = \"34\";\n  let my_image_filename = \"sgflkjdsdfrglhg.jpg\"\n\n  jQuery(\"#my_image_id_\" + my_image_id_value).attr(\"src\", \"\/live_camera_images\/\" + my_image_filename);     \/\/&lt;&lt;&lt;&lt;&lt;Don't forget the \"#\" at the start of the ID name!!!<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Changing an image src Using jQuery to change an image src<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[98],"tags":[],"class_list":["post-926","post","type-post","status-publish","format-standard","hentry","category-images"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/comments?post=926"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/926\/revisions"}],"predecessor-version":[{"id":4287,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/926\/revisions\/4287"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/media?parent=926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/categories?post=926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/tags?post=926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}