Add css via javascript -


hy, maybe stupid question , tottaly easy, can't make work please help. here's code.

asp=height / width * 100; document.getelementbyid("head_wrap").style["padding-top"] = "'+asp+%'";  

using alert(asp); gives correct value, made mistake here "'+asp+%'", want value in percentages said doesn't work. help!

you have syntax errors in set value double quotes , single quotes. use property style object, sample:

asp = height / width * 100; document.getelementbyid("head_wrap").style.paddingtop = asp + "%";  

alternativally, use did, adjusts in code.

asp = height / width * 100; document.getelementbyid("head_wrap").style["padding-top"] = asp + "%; 

i modified jsfiddle, take look here.

see also


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -