gpt4 book ai didi

javascript - jquery 更改背景图像不起作用

转载 作者:行者123 更新时间:2023-12-03 07:25:17 24 4
gpt4 key购买 nike

function slideSwitch() {
$("#bgvid").css("background-image", "url(/assets/images/home_page/auckland.jpg)");
}

$(function() {
setInterval( "slideSwitch()", 5000 );
});

enter image description here

enter image description here

它应该在 url 路径中显示我的网站名称,因此我将其添加到 jquery:

function slideSwitch() {
$("#bgvid").css("background-image", "url(the_vegan_repository/assets/images/home_page/auckland.jpg)");
}

并得到:

jquery.js:6685 GET http://localhost:8888/the_vegan_repository/the_vegan_repository/assets/images/home_page/auckland.jpg 404 (Not Found)

如何通过将其指向 the_vegan_repository/assets/images/home_page/auckland.jpg 来找到我的资源?

最佳答案

试试这个:

function slideSwitch() {
$("#bgvid").css("background-image", "url('/the_vegan_repository/assets/images/home_page/auckland.jpg')");
}

$(function() {
setInterval( "slideSwitch()", 5000 );
});

关于javascript - jquery 更改背景图像不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36026968/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com