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

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -