【问题标题】:Replacing default images in Squarespace with JQuery用 JQuery 替换 Squarespace 中的默认图像
【发布时间】:2018-08-26 19:05:01
【问题描述】:

我正在尝试用自定义图像替换网站上的视频图标。我以为我在页脚中有代码并使用了 attr 功能,但我没有得到任何结果。我错过了什么?

该图标位于我的客户网站http://www.sunsetstudiosent.com“电影”部分的 YouTube 视频链接上

还有我目前的代码:

  <script>
    $(document).ready(function () {
      $(".sqs-video-icon").attr("src", "https://static1.squarespace.com/static/50e3caa8e4b0c2f4977139be/t/5aad883e88251b563049bb78/1521322046538/play_icon.png");
    });
  </script>

它似乎是从 Squarespace 上的库存图片中搜索 url,但我不确定如何让这个更改生效。

image code window for url

.sqs-video-wrapper .sqs-video-overlay .sqs-video-icon {
    background-image: url('//static.squarespace.com/universal/images-v6/damask/play-button@2x.png');
    background-size: 33px;
}
.sqs-video-wrapper .sqs-video-overlay .sqs-video-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    background: transparent url('//static.squarespace.com/universal/images-v6/damask/play-button.png') center center no-repeat;
        background-image: url("//static.squarespace.com/universal/images-v6/damask/play-button.png");
        background-size: auto auto;
    height: 48px;
    width: 48px;
    margin-left: -24px;
    margin-top: -24px;
    cursor: pointer;

谢谢。

【问题讨论】:

    标签: jquery image replace attributes squarespace


    【解决方案1】:

    您可以在“sqs-video-icon” div 中插入“img”标签并使用以下代码:

    $(document).ready(function () {
      $(".sqs-video-icon > img").attr("src", "https://static1.squarespace.com/static/50e3caa8e4b0c2f4977139be/t/5aad883e88251b563049bb78/1521322046538/play_icon.png");
    });
    

    【讨论】:

    • 这并没有改变什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-02
    • 1970-01-01
    • 2011-04-28
    • 2022-01-06
    • 1970-01-01
    • 1970-01-01
    • 2015-06-03
    相关资源
    最近更新 更多