Is it possible to get an HTML attribute to CSS? -


i'm making carousel , wanna set background image every carousel item , want background image same image that's inside item, image has src attribute , want css automatically set background

sorry bad english

it can done javascript

suppose, have <img> like

<img id="my_img" src="my_img_src"/> 

then, can src of <img> follows

var myimgsrc = document.getelementbyid("my_img").src; 

now, variable myimgsrc holds src of <img>.

again using javascript can use variable set css like,

document.getelementbyid("my_img").style.backgroundimage = "url('"+myimgsrc+"')"; 

try this..


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -