Add another class to a div

前端 未结 7 967
盖世英雄少女心
盖世英雄少女心 2020-11-29 07:29

I have a function that checks the age of a form submission and then returns new content in a div depending on their age. Right now I am just using getElementById to replace

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 07:30

    In the DOM, the class of an element is just each class separated by a space. You would just need to implement the parsing logic to insert / remove the classes as necesary.

    I wonder though... why wouldn't you want to use jQuery? It makes this kind of problem trivially easy.

提交回复
热议问题