简体   繁体   English

jQuery Mobile Change页面上的正文背景图像更改

[英]jQuery Mobile Change body background image on page change

I have the following scenario, two pages with different body id. 我有以下情况,两个页面具有不同的主体ID。 This is for setting a different background on each body. 这是为了在每个主体上设置不同的背景。 However when I navigate to page2 from page1 the background keeps being the same. 但是,当我从page1导航到page2时,背景保持不变。 Is there a way to set a background image on page change ?? 有没有办法在页面更改上设置背景图像?

PAGE1: 第1页:

HTML:
<body>
   ...html content
</body>

PAGE 2: 第2页:

HTML:
<body id="myOtherBg" >
   ...html content
</body>

CSS: CSS:

 body{
        background: url(../img/background_white.png) center center no-repeat;
    }

    #myOtherBg{
        background: url(../img/background_white.png) center center no-repeat;
    }

This works on a normal page load, but when reaching the page2 from page1 using jquerymobile the background doesn't change. 这适用于正常的页面加载,但是使用jquerymobile从page1到达page2时,背景不会改变。

Any help would be appreciated, thanks in advance. 任何帮助将不胜感激,在此先感谢。

Try giving page1's body tag an id and target that in your first rule. 尝试给page1的body标签指定一个ID,然后在第一个规则中定位该ID。 So instead of body{...} , make it #firstBG{...} . 因此,不要使用body{...} ,而是使其成为#firstBG{...} That way page2 does not even attempt to pull the first page's background. 这样page2甚至不会尝试拉出第一页的背景。

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

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