• Resolved brendand0

    (@brendand0)


    Hello,

    Can you give me a script that I can add to the functions.php of my child theme so that the “jdgm-rev-widg__title” class available in the reviews of my products, changes from an h2 tag to a p tag?

    Thanks for your help! ??

    Brendan

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support abdou1021

    (@abdou1021)

    Hello Brendan,
    Thank you for reaching out to us.

    You can try using the following script :
    document.addEventListener(“DOMContentLoaded”, function(){
    setTimeout(() => {
    $(‘.jdgm-rev-widg__title’).replaceWith(function() {
    return $(“<p>”, {
    class: this.className,
    html: $(this).html()
    });
    });
    }, “1000”)
    });


    Let us know if you need any furthe rhelp.

    Kind regards
    Abdessadek

    Thread Starter brendand0

    (@brendand0)

    Hi Abdessadek,

    Thanks for your quick reply!

    I’ve added the code, and if you go to one of my product sheets, for example: https://apimani.fr/produit/porte-savon-aimante/?nowprocket

    You’ll see that the code has been added, but it leaves “jdgm-rev-widg__title” in h2. Do you have an explanation or another solution?

    Thanks again for your help!

    Have a good week, see you soon.

    Kind regards,

    Brendan

    Plugin Support abdou1021

    (@abdou1021)

    Hello Brendan,

    I checked and I can see the reason is because the $ is not defined. Which means the jQuery is missing.
    Try to add this before the script :
    <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js” type=”text/javascript”></script>

    Otherwise, you can completely replace the first code I gave you with the following (this way you won’t need jQuery) :

    document.addEventListener(“DOMContentLoaded”, function () { setTimeout(function () {
    var titleElements = document.querySelectorAll(“.jdgm-rev-widg__title”); titleElements.forEach(function (element) {
    var newElement = document.createElement(“p”);
    newElement.className = element.className;
    newElement.innerHTML = element.innerHTML; element.parentNode.replaceChild(newElement, element);
    });
    }, 1000);
    });


    I hope this helps.

    Kind regards
    Abdessadek

    Thread Starter brendand0

    (@brendand0)

    Hi Abdessadek,

    Thanks for your quick reply and your help!

    It works perfectly! It’s great ??

    Have a good week, see you soon.

    Kind regards,

    Brendan

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change tag h2 to p of “jdgm-rev-widg__title”’ is closed to new replies.