Home Forums WoodMart support forum Add class by code + one bug

Add class by code + one bug

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #225710

    atpd23
    Participant

    Hi,

    I would like to ask you, how to add class by JavaScript code? I have tried this piece of code added into Custom JS:

    var target = document.getElementsByClassName("addhere")[0];
    target.addClass('class1');
    targetDiv.classList.add("class2");

    Neither ‘class1’ nor ‘class2’ were added into my existing class ‘addhere’. Actually, I can see that ‘addhere’ class exist by Inspect the website and only one class is named like ‘addhere’ class. Is there any mistake in to code above?

    ———

    The next question is about a bug. I set ‘Disable OWL Carousel script on mobile devices’ OFF, but after some websites refreshes it automatically set to ON.

    Best Regards

    #225766

    Artem Temos
    Keymaster

    Hello,

    1. You can use the following code to add some CSS class to element with class addhere

    jQuery('.addhere').addClass('some-class');

    Put the code to the Custom JS section on the document ready in Theme Settings.

    2. Please, disable all external plugins and send us your admin access. Write an instruction about how to reproduce the problem step by step.

    Kind Regards

Viewing 2 posts - 1 through 2 (of 2 total)