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