Reputation: 1
I'm working on a new website, i'm using a background image rotaror (after refresh). I made a switch where you can turn on/off the background image.
I found some scripts that can do it with div's but not with the body in css. So when the on/off switch is click i need to get "background:" removed.
Can somebody help me out with a jquery/javascript script?
body {
margin: 0;
padding: 0;
background: url("../img/landingpage/background/random.php") fixed no-repeat;
background-size: cover;
color: white;
font-family: verdana;
}
Upvotes: 0
Views: 421
Reputation: 1
I've made it work now, with the toggle function
$("#myonoffswitch").toggle(
function (){
$("body").css("background", "none");
}
,
function (){
$("body").css("background", "url('http://p1.pichost.me/640/27/1502004.jpg')");
}
);
JSFIDDLE: http://jsfiddle.net/A97G3/
Upvotes: 0
Reputation: 1923
$("#switch").on("click", function () {
$("body").css("background", "none");
});
Upvotes: 1
Reputation: 10182
Using jQuery you can do something like this:
$('body').css('background' : '');
Upvotes: 1