View Full Version : simple getDocumentbyID question

12-10-2004, 06:06 PM
I have a table in which i need certain cells to have a certain background image. I figured the the best way to do this would be as follows:

unfortunantly this code is syntactically incorrect. what is the right syntax?

document.getElementById("backgroundCells").background = 'images/t28_17.gif';

also, i need to apply this to multiple cells on one page, so it cant be document.getElementById is has to be document.getElementByClass.

can i even do this?

12-10-2004, 06:26 PM
If they all have the same bg image then just give them a class and assign the bg image with css. If there are multiple images make multiple classes, or give each a unique ID if they are all different bgs. Unless you want to change the bg on the fly I don't really see the need for the JS.


12-10-2004, 07:56 PM
good thinking

so i do this:

{ baground-image: images/t28_17.gif }


12-10-2004, 08:02 PM
got it

<style type="text/css">
{ background-image: url('images/t28_17.gif') }