CSS
background-image:url(../back/back01.jpg); //this works
JS
function switchRight(){
$('#slider00').css("background-image","url(../back/back02.jpg)");
}
back01.jpg is removed, but back02.jpg is not loaded.
CSS
background-image:url(../back/back01.jpg); //this works
JS
function switchRight(){
$('#slider00').css("background-image","url(../back/back02.jpg)");
}
back01.jpg is removed, but back02.jpg is not loaded.
Make sure that you image is exist in defined folder.
You can also give css class by below code.
.imageclass
{
background-image:url(../back/back01.jpg);
}
function switchRight(){
$('#slider00').addClass('imageclass'); // same way you can use remove class
}
Assume your css files in folder
function switchRight(){
$('#slider00').css("background-image","url(back/back02.jpg)");
}
Please check
It is because of the path to the background image. When setting it via css the path is relative to where your css file is located. When you do it in javascript use path relative to the root of the application.
You may need to check the the path for image. The first is based on the css file's current path, while the second is based on web site root.
Try this
$('#slider00').css("background-image", "url(../back/back02.jpg)");
$('#slider00').click(function()
{
// do my image switching logic here.
});