简体   繁体   中英

Set IE specific css styles via javascript

I'm trying to set a CSS property, that is specific to IE, via javascript. Something like the following

document.body.style.-ms-content-zooming = "zoom";

or

document.body.style.-ms-scroll-snap-x = "whatever"

But the css property doesn't get set the way shown above (I tried the first line for sure). How could I accomplish the above task, or setting any css starting with a dash ( - ) for that matter, using javascript ?

I do not have an Internet Explorer at hand but usually styles containing dashes are camelcased like:

document.body.style.msContentZooming = "zoom";

See this MSDN Blog post

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM