javascript - store image src in a js variable so that it can be used to display background image -


how store image src of above image tag in javascript variable?

<img class="preview" alt="styling bandana" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/389177/bacon.jpg" onmouseover="update(this)" onmouseout="undo()"> 

i need url can enter in here

document.getelementbyid("image").style.backgroundimage = "url(' + imgsrc + ')"; 

and background image

jquery = .attr('src'); js = .getattribute('src'); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -