jquery - How can i retrieve an image of <img> tag into the variable in javascript? -


how can image of <img> tag , store in variable in javascript (or equivalently jquery) ?

(actually want swap images between 2 <img> tags).

jquery has specific uses .prop() vs .attr() make sure read on that: http://api.jquery.com/attr/

but once assigned src of 1 image variable:

var img1_src = $("img#image1").attr("src"); 

you can take variable , shove source of image:

$('img#img2').attr('src', img1_src); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -