Add another class to a div

前端 未结 7 917
盖世英雄少女心
盖世英雄少女心 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:48

    You can append a class to the className member, with a leading space.

    document.getElementById('hello').className += ' new-class';
    

    See https://developer.mozilla.org/En/DOM/Element.className

    0 讨论(0)
提交回复
热议问题