Forum Moderators: open
I want to do a check to see what the background image is for a certain table cell. I've tried all sorts of things, but it never works. My current statement that errors is this:
"if(document.x4y5.style.background == 'grass.gif')"
x4y5 is the id of the table cell. I need that to be a variable eventually, but it would be nice to have at least one work for now.
Can anyone suggest the best way to do this using only javascript?
Thanks,
Jslice
Any other suggestons? I'm still messing with it, I'll post some more code when I figure out which part needs work...
thanks,
Jslice
Followup Info: It works if I set it to say!= 'grass.gif' so it must think it's something else. Is there anything about this line that makes it wrong?
<TD background="grass.gif" id=x4y5>
also, with a little further testing, it says that the background is undefined. Do I need to pass something into the function to make this work? I thought things in the document were global info...
It looks like your script is looking for a style attribute, not the background attribute, which is what your TD tag has. Does it work if you change the TD tag to
<TD style="background:'grass.gif';" id="x4y5">
<added> Yeah, I'm slow. Glad you got it figured out. :) </added>
[edited by: garann at 6:16 pm (utc) on July 16, 2003]
background: 'grass.gif'; == background: url(grass.gif); ==
background-image: 'grass.gif'; == background-image: url(grass.gif);
.. Right?
Whatever you put in your JavaScript just has to reflect the sytax you used in the stylesheet.