Insert css class in Javascript

Hey am new web developer and am working on a quote website project.

Please visit my CodePen project to understand the question clearly or else you cannot understand the question. Just click any copy button in CodePen.

As you saw my CodePen, there are many quotes with copy button. Remember that these copy button and quotes are displayed through Javascript so you cannot find its element in Html in CodePen.

Now my problem is, as you can see there are many quotes. I need a <div class="newclass"> element to be inserted for every two quotes, that is <div class="newclass"><div class="latestatus"><p>1The cat is better than dog.</p> <button class="copystatus btn">Copy</button></div><div class="latestatus"><p>2Google is a open source library.</p> <button class="copystatus btn">Copy</button></div></div>

As you see above they are two quotes of the CodePen project. I need <div class="newclass"> to surround every two quotes.

I have consulted my friend to solve this problem but none of them got. Am new to javascript so am not aware of this.

Again I will tell my problem that, I need <div class="newclass"> to surround every two quotes (not for only first 2 quotes).

Remember that I don’t have access to the quotes element because they are created from javascript that is I can change the overall appearance not single.

I hartley thanks for those who answer this question.

22 thoughts on “Insert css class in Javascript”

Leave a Comment