Changing DIV background with javascript...

Discussion in 'JavaScript' started by redhits, Nov 9, 2009.

  1. #1
    I know there is a way to change a DIV HTMT text using javascript, but is there any way to change the DIV background image? or background color?
     
    redhits, Nov 9, 2009 IP
  2. TSH-Nathan

    TSH-Nathan Greenhorn

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #2
    You should check out the use of document.getElementById().style - that's should point you in the right direction. Just search google and you'll find lots of results.
     
    TSH-Nathan, Nov 9, 2009 IP
  3. rajesharma470

    rajesharma470 Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This should help
    document.getElementById("divID").style.backgroundImage = 'web/images/image.gif';
     
    rajesharma470, Nov 10, 2009 IP
  4. ajaXpert

    ajaXpert Member

    Messages:
    41
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #4
    here is the list:
    document.getElementById("div_id").style.backgroundColor = "#ff0000";
    document.getElementById("div_id").style.backgroundImage = "url(image_url)";
    document.getElementById("div_id").style.backgroundPosition = "top right";
     
    ajaXpert, Nov 26, 2009 IP