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

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -