Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing BackGround Image Onclick.

Status
Not open for further replies.

soonkhoo

Programmer
Dec 8, 2000
133
MY
Hi,

I hope my topic didn't confuse people. But I'm wondering if there's a way to change the back ground image(not color)dynamically when a button is clicked? Also, can it be target specific? Thanks.

SOon
 
Do you mean the background of a BODY, TABLE or TD or what HTML element? You're only as good as your last answer!
 
Yes, you can change basically anything you like, so long s you can access it via JavaScript- a function which accsses like:

function changeBg(){
elementName.style.backgroundImage = "url('newImageURL')"
}

Just have to make sure to use the whole thing including the url part and brackets - really you are just inserting a new value after the : in the style defintion , so you must include everything, it will not understand just an URL by itself. ;)
b2 - benbiddington@surf4nix.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top