Home  >  Article  >  Web Front-end  >  js setattribute sets css styles in batches_javascript skills

js setattribute sets css styles in batches_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:41:091849browse

Firefox, etc. can use
var dom=document.getElementById("name");
dom.setAttribute("style","width:10px;height:10px;border:solid 1px red;");

In IE, style.cssText must be used

var dom=document.getElementById("name");
dom1.style.cssText = "width:10px;height:10px;border: solid 1px red;";

To add, style.cssText is now similar to innerHTML and has become a de facto standard for web development. So the test shows that the firefox browser also supports this method.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn