W warezrock Active Member 704 2009 23 0 Sep 2, 2010 #1 i want to change the background image of a div onclick Example:- Code: http://bytes.com/topic/javascript/answers/777843-change-background-image-onclick look at the top green color buttons.. any help how to do this ?
i want to change the background image of a div onclick Example:- Code: http://bytes.com/topic/javascript/answers/777843-change-background-image-onclick look at the top green color buttons.. any help how to do this ?
Porsche_maniak Active Member 283 2009 0 40 Sep 3, 2010 #2 I think there are few ways to do that ! This should help Code: <div onclick=this.style.backgroundImage='url(YOURBG.JPG)';>TEXT with bgimage</div> You can also add the all onclick thing in <input type=button onclick=this.style.backgroundImage='url(images/bg.jpg)';>
I think there are few ways to do that ! This should help Code: <div onclick=this.style.backgroundImage='url(YOURBG.JPG)';>TEXT with bgimage</div> You can also add the all onclick thing in <input type=button onclick=this.style.backgroundImage='url(images/bg.jpg)';>
L litewarez Active Member 1,367 2008 1 0 Sep 3, 2010 #3 why dont you use a library? like jQuery Code: $('.mybutton').click(function(){ $(this).css({'background-image':'url(........)'}); });
why dont you use a library? like jQuery Code: $('.mybutton').click(function(){ $(this).css({'background-image':'url(........)'}); });