JavaScript添加和删除Class
//Add Class document.getElementById("MyElement").className += " MyClass"; //Remove Class document.getElementById("MyElement").className = document.getElementById("MyElement").className.replace(/(?:^|\s)MyClass(?!\S)/,'');
JavaScript添加和删除Class
//Add Class document.getElementById("MyElement").className += " MyClass"; //Remove Class document.getElementById("MyElement").className = document.getElementById("MyElement").className.replace(/(?:^|\s)MyClass(?!\S)/,'');