节点属性和节点对象属性

getAttribute('attribute') normally returns the attribute value as a string, exactly as defined in the HTML source of the page.

However, element.attribute could return a normalized or calculated value of the attribute. Examples:


a.href will contain full URL


input.checked will be true (boolean)


input.checked will be true (boolean)


img.width will be 0 (number) before the image is loaded
img.width will be 64 (number) when image (or first few bytes of it) is loaded


img.width will be the calculated 50%


img.width will be 50 (number)

div.style will be an object

节点属性和节点对象属性_第1张图片
attributes

你可能感兴趣的:(节点属性和节点对象属性)