< div id =" somewhere" class =" some_class some_other_class"> < script type =" text / javascript"> function changeClass(what,original,newOne){ what = document.getElementById(what); what.className = what.className.replace(original,newOne); } < / script> < button onclick =" changeClass(''somewhere'',''some_other_class'',''new_class'')"> 更改1 < / button> < button onclick =" changeClass(''somewhere'',''some_class'' ,''new _other_class'')"> 更改2 < / button> - sm <div id="somewhere" class="some_class some_other_class"><script type="text/javascript">function changeClass(what, original, newOne) {what = document.getElementById(what);what.className = what.className.replace(original, newOne);}</script><button onclick="changeClass(''somewhere'',''some_other_class '',''new_class'')">change 1</button><button onclick="changeClass(''somewhere'',''some_class'',''new _other_class'')">change 2</button> --sm 这篇关于改变多个类名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-18 00:30