how do i change woocommerce class using javascript?

You must target the correct element to make it work. In your code you are trying to target an element with the id main.

I would recommend using document.querySelector() So your code would be:

<script type="text/javascript">
// select element        
var ourElement=document.querySelector(".elementor-widget-container .woocommerce.columns-3");
ourElement.classList.remove('columns-3');
ourElement.classList.add('columns-4');
</script>

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top