简体   繁体   中英

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

I have this JQuery code (in a file called 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.

Any help will be much appreciated. Thanks in advance.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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