如何将类添加到给定的元素? - How do I add a class to a given element?

问题:

I have an element that already has a class: 我有一个已经有一个类的元素: html

<div class="someclass">
    <img ... id="image1" name="image1" />
</div>

Now I want to create a JavaScript function that will add a class to the div (not replace, but add). 如今,我想建立一个JavaScript函数,该函数将向div添加一个类(不是替换,而是添加)。 ide

How can I do that? 我怎样才能作到这一点? 函数


解决方案:

参考一: https://stackoom.com/question/27ve/如何将类添加到给定的元素
参考二: https://oldbug.net/q/27ve/How-do-I-add-a-class-to-a-given-element
相关文章
相关标签/搜索