Resize background image in javascript

I am trying to put a repeating background image on a website with basic CSS

background-image: url('url_here');
background-attachment: fixed;
background-repeat: repeat;

however, id would like to be able to resize the image im using when updating using javascript. CSS has a function

background-size: 300px;

but unfortunately, the COM style object doesnt - see here for what it can do for the background. This leaves me with one option: using an HTML image that repeats, which I can edit with a COM style object.

So, cooked, my question is: is there a way to repeat an HTML image that is NOT a background image? Any help is greatly appreciated.

+5
source share
2 answers

, javascript :

document.getElementById("el_id").style.backgroundSize = "100px 100px";

: http://jsfiddle.net/Lph2W/. CSS 200px X 200px, JS 100px X 100px.

+11

, , - .

var el = document.getElementById("notification");
el.style.background = 'url(images/Noti.png) no-repeat center center';
el.style.backgroundSize="100% 100%";

, , UP:)

+3

All Articles