How to add new class in div via javascript?

Hello Everyone i am using wordpress slider but i want to add new class in slider <li> via javascript.

<div class="wp-slider">
 <ul>
 <li></li>
 </ul>
</div>

Related posts

Leave a Reply

1 comment

  1. In Javascript :

    document.querySelector('.wp-slider ul li').classList.add('MyClass')
    

    (or in JQuery 🙂

    $('.wp-slider ul li').addClass("MyClass")