...

onclick Background

Erindesign
02-22-2007, 07:54 PM
I have an input form that has a background image set by default. I need to make it change background on click.

What is the codeof this? (I need something like <input bla blabla onclick="...">)

I looked on google but they all had complicated JS.

Thanks in Advance, Erind

Arbitrator
02-22-2007, 08:01 PM
CSS:
.myBackground { background-image: url("image.png"); }

HTML:
<input type="…" onclick="this.className = 'myBackground';">

If it has another background assigned via something with greater specificity, such as an ID, then you may need to use background-image: url("image.png") !important. You could also use this.style.backgroundImage, but I prefer to keep all of my CSS in one place.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum