請教下代碼divs[this.id].style.display="block";為什么不可以這么寫呢divs[this.id].style="display:block";?
請教下代碼divs[this.id].style.display="block";為什么不可以這么寫呢divs[this.id].style="display:block";?
請教下代碼divs[this.id].style.display="block";為什么不可以這么寫呢divs[this.id].style="display:block";?
2015-06-23
舉報
2015-06-24
divs[this.id].style.display="block" 這個表示把divs[this.id]里的display這個屬性設置為block;
而divs[this.id].style="display:block";表示把divs[this.id]的樣式設置成display:block,前者改變局部樣式,后則是改變這個div的全部樣式
2015-06-24
node.style是一個CSSStyleDeclaration對象不是字符數據,因而不能直接給起設置字符串類型值.如果想通過字符串直接賦值,可以通過node.setAttribute("style","****")或者node.style.cssText=""來設置.