使用方形空间上的文本更改innerHTML

时间:2014-09-21 00:52:51

标签: javascript html innerhtml squarespace

我试图采取"售罄"在this page并将其更改为"即将推出。"

现在我有以下但是它不起作用。

window.onload = function() {
  document.getElementsByClassName("product-mark sold-out").innerHTML = "Coming Soon";
};

1 个答案:

答案 0 :(得分:2)

window.onload = function(){
     //this captures all the elements with the spec classes
     var soldItems = document.getElementsByClassName('product-mark sold-out');

     //this changes each element 1 by 1 to new text
        for(var i=0; i<soldItems.length; i++){
           soldItems[i].innerHTML = "Coming Soon";
        }

}

应该照顾它!