如何將類添加到給定的元素? - 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
相關文章
相關標籤/搜索