Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在开发一个非常简单的所见即所得,并想在编辑器中编辑图像。这是纯 JavaScript 中修改图像类名称的最佳方式。
谢谢你。
您可以使用.setAttribute()方法,或设置.className属性。
.setAttribute()
.className
el.setAttribute('class', 'myClass'); el.className = 'myClass';