In the DOM operation on the page in the <style></style> style of operation, found invalid, I think it is because the page Dom parsing the label's style content will be read into memory, so JS operation can not get the contents of this tag
The style of a tag may be defined by more than one style file, so the browser in the interpretation of the label will have a way to calculate the last style of the label, want to change the style of the label in <style> defined format must go to the last browser computer computed style, Here, using the Currentstyle method under obj, the specific test is as follows:
"Text/css">div{width:300px; height:300px; Border-bottom:1px solid black; }. test1{background:red; }. test2{Background:green; }</style><script type="Text/javascript">function GetStyle (obj,attr) {returnObj.currentstyle? OBJ.CURRENTSTYLE[ATTR]: getComputedStyle (obj,NULL) [attr]; //return getComputedStyle (obj,null) [attr];} function T () {varm = document.getElementsByTagName ('Div')[0]; Console.log (m); Console.log (M.classname); if(!m.classname.indexof ('test1') ) {M.classname='test2'; //alert (m.style.width); }Else{m.classname='test1'; } //alert (GetStyle (M, ' width ')); //return;GetStyle (M,'width') = parseint (GetStyle (M,'width')) +5; M.style.height= parseint (GetStyle (M,'Height')) +5; M.style.borderbottom= parseint (GetStyle (M,'BorderBottom')) +1; }</script><divclass="test1"onclick="t ();">It's a special effect .</div>The ternary operator is used because IE6 only
getComputedStyle (obj,null) [attr]
This allows you to manipulate the style.
Get the last style of the DOM element in memory to modify the Currentstyle method under obj