changing body background with javascript?

Discussion in 'JavaScript' started by kakkalo, Apr 13, 2009.

  1. #1
    i am trying to make a body background switcher. where user will have couple of buttons, so that when they click on it body bg will change. also, it will save some sort of cookie so that the user go to another page or come bak it will remember that selection

    http://mangafox.com/ has this backgound selector thing.
     
    kakkalo, Apr 13, 2009 IP
  2. JavaScriptBank.com

    JavaScriptBank.com Peon

    Messages:
    141
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    JavaScriptBank.com, Apr 15, 2009 IP
  3. jqueryHowto

    jqueryHowto Guest

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can also use jQuery to easily achive this effect:

    $('body').css('background-color', '#ccc');
    Code (markup):
    or on button click:

    $('#button1').click(function(){
        $('body').css('background-color', '#ccc');
    });
    
    $('#button2').click(function(){
        $('body').css('background-color', '#fefefe');
    });
    Code (markup):
     
    jqueryHowto, Apr 16, 2009 IP