javascript - changing a class' style

前端 未结 5 1014
一整个雨季
一整个雨季 2020-12-15 18:33

I\'ve been working with jQuery for a while, but now I want to write something in pure javascript and it\'s prooving to be challenging.. One of my biggest problems at the mom

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 19:05

    You can use:

    document.getElementById("MyElement").className = "NewClass";
    

    to change the class of the element and then just define the style for that new class in your CSS file

提交回复
热议问题