Can't use javascript on a button

How can I add a simple javascript on this button with class add-to-cart?:

1 Like

I have added this script but it doesn’t work:

@Hamza3351 try this

document.addEventListener(‘DOMContentLoaded’, function() {
var addToCartButton = document.querySelector(‘.add-to-cart’);

if (addToCartButton) {
// Option 1: Change the style directly
addToCartButton.style.border= ‘3px solid red’;

    // Option 2: Add a CSS class
    addToCartButton.classList.add('my-custom-class');
}

});

1 Like

Yeah it works thanks