1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Why is this not working

Discussion in 'JavaScript' started by chiller4life, Oct 19, 2011.

  1. #1
    <input type="Button" value="Colour One" onclick="document.bgColor = 'Red'" />

    <input type="Button" value="paypal" onclick="document.bgColor = 'Blue'" />

    <input type="Button" value="Colour Three" onclick="document.bgColor = 'Green'" />

    i am using this script but my webpage is not changing colours

    like in css you write >>>!important <<< at the end is there anything similar in javascript like that
     
    chiller4life, Oct 19, 2011 IP
  2. HowDoYou

    HowDoYou Well-Known Member

    Messages:
    442
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    130
    #2
    Use Jquery. much more simple, and powerfull.
     
    HowDoYou, Oct 19, 2011 IP
  3. thedanielsolution

    thedanielsolution Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    2
    Trophy Points:
    0
    #3
    thedanielsolution, Oct 19, 2011 IP
  4. chiller4life

    chiller4life Member

    Messages:
    108
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #4
    so is jqueary better then javascripts and do you know any website which has good tutorials and good way to learn thank you
     
    chiller4life, Oct 19, 2011 IP
  5. HowDoYou

    HowDoYou Well-Known Member

    Messages:
    442
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    130
    #5
    HowDoYou, Oct 19, 2011 IP
  6. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #6
    You don't need jQuery for something as simple as this. In any case, it should be working properly. Try the following:
    <html>
    <body>
    <input type="Button" value="Colour One" onclick="document.bgColor = 'Red'" />
    <input type="Button" value="paypal" onclick="document.bgColor = 'Blue'" />
    <input type="Button" value="Colour Three" onclick="document.bgColor = 'Green'" />
    </body>
    </html>
    Code (markup):
     
    Rainulf, Oct 19, 2011 IP
  7. JohnnySchultz

    JohnnySchultz Peon

    Messages:
    277
    Likes Received:
    4
    Best Answers:
    7
    Trophy Points:
    0
    #7
    its better to use document.body.bgColor rather than document.bgColor..

    <input type="Button" value="Colour One" onclick="document.body.bgColor = 'Red'" />
    
    <input type="Button" value="paypal" onclick="document.body.bgColor = 'Blue'" />
    
    <input type="Button" value="Colour Three" onclick="document.body.bgColor = 'Green'" />
    HTML:
     
    JohnnySchultz, Oct 20, 2011 IP