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
Post a Comment