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