简体   繁体   English

为什么此代码未按预期更改背景图像?

[英]Why is this code not changing the background-image as expected?

I have this JQuery code (in a file called home_main_post.js ): 我有这个JQuery代码(在一个名为home_main_post.js的文件中):

$(document).ready(function() {
    searchQuery();
});
function searchQuery() {
    var searchBoxIcon = $('i.main.search.link.icon');
    var searchInput = $('.prompt.search-box');
    searchBoxIcon.click(function() {
        $('body').css('background-image', 'linear-gradient(rgba(0, 0, 0, 0.6),rgba(0, 0, 0, 0.0)), url(../Images/library_background.png)');
    })
}

Now the problem is that when I click on the search button I have, it changes the background but only the linear gradient is applied. 现在的问题是,当我单击具有的搜索按钮时,它会更改背景,但仅应用线性渐变。 The rest is white. 其余为白色。 I think it is not being able to locate the image. 我认为无法找到图像。 My folder structure: 我的文件夹结构:

资料夹结构

I have also tried ./Images/..... , /Images/..... but to no avail. 我也尝试过./Images/..... /Images/.....但无济于事。

Any help will be much appreciated. 任何帮助都感激不尽。 Thanks in advance. 提前致谢。

该library_background具有.jpg格式,请查看,我也看到您突出显示了具有.png格式的home_background,请更改格式或图像,希望对您有所帮助,thnx。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM