javascript change image src
//change image src
document.getElementById('myImageID').src="images/my_other_image.png";document.getElementById("myImg").src = "hackanm.gif";// Pure JavaScript to Create img tag and add attributes manually ,
var image = document.createElement("img");
var imageParent = document.getElementById("body");
image.id = "id";
image.className = "class";
image.src = searchPic.src; // image.src = "IMAGE URL/PATH"
imageParent.appendChild(image);
// Set src in pic1
document["#pic1"].src = searchPic.src;
// or with getElementById
document.getElementById("pic1").src= searchPic.src;
// jQuery to archive this,
$("#pic1").attr("src", searchPic.src);
document.getElementById("imageid").src="../template/save.png";<a href='#' onclick='edit()'><img src="../template/edit.png" id="edit-save"/></a>
Also in JavaScript:
- 'App' is not defined react/jsx-no-undef
- append meta tag to head javascript
- how to display first value of an array in jquery
- how to not add id to url when click
- Angularjs datetime
- how to trim dates in react
- can the name of function be the same with name of variable js
- js alerts
- filter biggest value javascript object
- how to filter data from mongodb date in reactjs
- save json file python
- username validation js
- jquery hasclass
- Laravel react 404 routes
- perform a function on each element of array javascript
- angular calendar updating until hovering
- javascript parse to string
- js make radio checked
- javascript includes
- jquery get all classes of a div
- jquery get the length of input text
- react html symbol code
- ajax .put
- AngularJS SQL