These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:11 pm Advanced search

Changing a Table Background image

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

Changing a Table Background image

Postby THEL0SER » Tue Dec 21, 2010 4:03 pm

Hi, this is my first post here, but I will probably have more questions in the future.

I was wondering if I wanted to make a button change the background image of a table in HTML5 if I should still use java, or if their is a better way to do it now.

Thanks a lot!
THEL0SER
<h6>
 
Posts: 1
Joined: Tue Dec 21, 2010 3:57 pm
Location: USA

Postby Alan » Mon Jan 03, 2011 5:32 am

First things first, you mean JavaScript (a dynamically typed scripting language available in most browsers and some server-side implementations) not Java (a statically typed programming language that compiles to bytecode which can be executed on the Java VM and only be used in a browser with the relevant plugin). Apart from the name, the two have more differences than similarities.

If you want a button to change another element's styling, I don't really see another way to do it other than using JavaScript. It's really simply to do in JavaScript, too. You shouldn't need more than a single line of code (maybe three, if you want some readability).
Alan
<h5>
 
Posts: 18
Joined: Sun Oct 31, 2010 2:16 pm
Location: Cologne, Germany

Postby slothmister » Thu Jan 06, 2011 7:32 pm

You could possibly use CSS for this.

onClick is JS but a:hover is css as is a:active and many other options. Be ware though, this will not work in older browsers and is not the exact option you want, but could be used to replicate it.
slothmister
<h6>
 
Posts: 7
Joined: Tue Oct 19, 2010 8:06 am

Postby Alan » Fri Jan 07, 2011 10:42 am

I don't see how CSS can help. You can only use :hover/:active to style nested elements. You would have to nest the element with the background image inside the element (e.g. the button) you want to trigger the effect. Also, I'm pretty sure :hover propagates upwards (i.e. hovering over the background would trigger the same effect as hovering over the parent button) and :active can be cleared (by clicking elsewhere?).
Alan
<h5>
 
Posts: 18
Joined: Sun Oct 31, 2010 2:16 pm
Location: Cologne, Germany


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests