Friday, 15 May 2015

jquery - switch body colour based on class on container -



jquery - switch body colour based on class on container -

we using 1 index.html page includes tag, in css body set background colour #ddd. index.html page main template other pages included in. cant specify multiple background colours on body uses 1 index page.

the rest of pages included index.html, example: services.html start with:

<div class="container">services content here</div>

is possible css somehow add together class on container switch background colours on body? example:

<div class="container bgwhite">services content here</div> <div class="container bgdkgrey">contact content here</div> <div class="container bgblue">reviews content here</div>

then like:

body .container.bgwhite body {background:white;}

im not sure how this?

edit:

would not work on here posted:

$('.container').hasclass('bgwhite') { $('body').css('backround', 'white'); }

how multiple background colours though, if wanted switch between multiple background colours on body?

you can seek jquery, that:

if ( $(".container").hasclass("bgblue") ){ $("body").css('background', 'blue'); };

here fiddle: http://jsfiddle.net/tcjagypy/

jquery html css html5 css3

No comments:

Post a Comment