I'm new to jquery mobile and I have a need to change the background image dynamically. I tried the following codes but none is working.
-
//$('.ui-page').css('background-image', "url(img/background2.jpg) no-repeat center center fixed;");
-
//$('#index .ui-page').css('background-image', "url(img/background2.jpg) no-repeat center center fixed;");
-
$('body').css('background-image', "url(img/background2.jpg) no-repeat center center fixed;");
-
//$('#rodeliox').css('background-image', "url(img/background2.jpg) no-repeat center center fixed;");
-
//$('.ui-page').removeClass().addClass('.ui-page.bg2');
-
-
//document.getElementById("rodeliox").style.backgroundImage = "url(img/background2.jpg) no-repeat center center fixed;";
-
-
$('#index').trigger('pagecreate');
-
alert("test");
This is the css that I used to set the background image.
- #index.ui-page{
- background: url(img/background.jpg) no-repeat center center fixed;
- -webkit-background-size: cover;
- -moz-background-size: cover;
- -o-background-size: cover;
- background-size: cover;
- background-size:100% 100%;
- }
Can anyone help me? Thank you so much!