el = function(q) {return document.getElementById(q)};
el('strange').style.height = '100px'
el('strange').height = 2000
alert(el('strange').height) // 100?
alert(el('strange').getAttribute('height')) //2000? Wait.. What?
el是document.getElementById的簡寫。有人能解釋我發生了什麼事嗎?我懷疑高度屬性與高度屬性略有不同:他們修改它,以便它返回計算的樣式。我不確定,因爲DOM 0表示該屬性應該與getAttribute相同,但錨點的href屬性與大多數瀏覽器中的getAttribute不匹配。和:圖片尺寸奇數
https://developer.mozilla.org/en/DOM/HTMLImageElement
的HTML:
<img id="strange" src="http://images.devshed.com/fcw/belts/fcw_forums.gif" />
元素是否隱藏? :) – Blindy
不,我會添加這個例子的html ... – bopjesvla