我正在使用 JavaScript,如果单击按钮,我想添加/删除 Class 属性。我可以添加该类,但我不知道如何删除它。我怎样才能做到这一点?
window.onload = function(){
var buttonGo = document.getElementsByTagName('button')[0];
var buttonCom = document.getElementsByTagName('button')[1];
var box = document.getElementById('box');
buttonGo.onclick = function(){
box.setAttribute('class','move');
}
buttonCom.onclick = function(){
// how to remove class name?
}
}
box.removeAttribute("class")
应该管用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)