何时在JavaScript中使用setAttribute vs.Attribute=?有一个关于使用setAttribute而不是点(.)制定了属性表示法?例如:myObj.setAttribute("className", "nameOfClass");myObj.setAttribute("id", "someID");或myObj.className = "nameOfClass";myObj.id = "someID";
3 回答

ibeautiful
TA贡献1993条经验 获得超5个赞
setAttribute
node.className = 'test'; // works
node.frameborder = '0'; // doesn't work - non standard attribute
node.setAttribute('frameborder', '0'); // works
添加回答
举报
0/150
提交
取消