小编Pet*_*son的帖子

JavaScript 在 Squarespace 中只被调用一次

我的 SquareSpace 网站上有一些自定义 JavaScript,可以对产品标题进行操作,超出了 SquareSpace 默认样式编辑器的范围。它在最初加载页面(https://www.manilva.co/catalogue-accessories/)时有效,但如果您单击左侧的任何类别,样式将重置为默认值。

我假设 JavaScript 被 SquareSpace 样式覆盖,但我不明白为什么。也许我在错误的地方调用了该函数?

任何的意见都将会有帮助。

谢谢!

当前代码:

document.querySelectorAll(".ProductList-filter-list-item-link".forEach(i=>i.addEventListener("click", function()
  {
      var prodList = document.querySelectorAll("h1.ProductList-title");
  for (i = 0, len = prodList.length; i < len; i++) 
  {
    var text = prodList[i].innerText;
    var index = text.indexOf('-');
    var lower = text.substring(0, index);
    var higher = text.substring(index + 2);
    prodList[i].innerHTML = lower.bold() + "<br>" + higher;

  });
Run Code Online (Sandbox Code Playgroud)

javascript squarespace

4
推荐指数
1
解决办法
3031
查看次数

标签 统计

javascript ×1

squarespace ×1