Skip to main content

Attribute 与 Property

  • attribute:是 HTML 标签上的某个属性,如 id、class、value 等以及自定义属性
let demo11 = oDiv.getAttribute('class')
let demo2 = oDiv.setAttribute('data-name', 'new-value')
  • property:是 js 获取的 DOM 对象上的属性值,比如 a,你可以将它看作为一个基本的 js 对象。