Replacing entire tag with shortcode – JavaScript

I’m trying to replace a whole tag with a shortcode, if the tag text equals a value. I’m placing this script into the footer of the page. Here’s what I’m trying:

var stockcounter = document.getElementsByClassName(“stock in-stock”);

if(stockcounter[0].innerHTML==’0 in stock’) {
//Displays timer
stockcounter[0].outerHTML = do_shortcode(‘[fergcorp_cdt_single date=”Feb 25 2019 18:45:00″]’);
}

This doesn’t change the target tag at all. Does anyone know what I’m doing wrong?

Read more here:: Replacing entire tag with shortcode – JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *