473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Determine table cell image resides in

Here's what I'm trying to do:

When a user hovers the mouse over an image, I want the background of
the table cell it resides in to change color.

I know how to use the onMouseOver event to detect when the mouse is
hovering over the image, and how to change the background property of
a table cell.

My questions:

How do I address the table cell that contains the image?

Thanks in advance for the help!!!
Jul 23 '05 #1
3 1581
hi,
this should work..

--------------
<TABLE id="Table1">
<TR>
<TD><IMG src="abc.jpg"
onmouseover="this.parentElement.bgColor='black';"> </TD>
</TR>
</TABLE>
--------------

"midwesthills" <mi**********@hotmail.com> wrote in message
news:1f**************************@posting.google.c om...
Here's what I'm trying to do:

When a user hovers the mouse over an image, I want the background of
the table cell it resides in to change color.

I know how to use the onMouseOver event to detect when the mouse is
hovering over the image, and how to change the background property of
a table cell.

My questions:

How do I address the table cell that contains the image?

Thanks in advance for the help!!!

Jul 23 '05 #2
midwesthills wrote:
Here's what I'm trying to do:

When a user hovers the mouse over an image, I want the background of
the table cell it resides in to change color.

I know how to use the onMouseOver event to detect when the mouse is
hovering over the image, and how to change the background property of
a table cell.

My questions:

How do I address the table cell that contains the image?

Thanks in advance for the help!!!

<td onmouseover="something()" onmouseout="somethingElse()">.........</td>

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #3
On Mon, 20 Sep 2004 23:32:04 +0300, CarettaCare
<ca***************@HEREyahoo.com> wrote:
this should work..

--------------
<TABLE id="Table1">
<TR>
<TD><IMG src="abc.jpg"
onmouseover="this.parentElement.bgColor='black';"> </TD>
</TR>
</TABLE>
--------------


In Internet Explorer, yes, but in most other browsers it will cause an
error. It would also be better to use the style object (after testing for
it). The bgColor property, along with the bgcolor HTML attribute, is
deprecated in favour of style sheets.

See Randy's post for a simple solution. If the table cell is much larger
than the image, you can check the target/srcElement of the event object
for an image.

[snip]

Mike
Please don't top-post.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kai Grossjohann | last post by:
I have a table which contains a top-aligned table cell: .... <tr style="height:40"> ... <td colspan="1" rowspan="2" align="left" valign="top" style="overflow:hidden;">...
61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
3
by: Thomas Mlynarczyk | last post by:
Hello, How can I make an <a> element (containing text only, styled to be a box with a border) as big as the table cell in which it resides, *without* having specified any width/height (neither...
7
by: Andrew Poulos | last post by:
I'm using the following code to create a small table with one column and two rows. An image goes into the first cell. //create table var t = document.createElement("TABLE"); t.style.position =...
5
by: Greg N. | last post by:
Hi folks, I have a table cell with a background image, something like <td background=landscape.jpg height=200></td> The sole purpose of this code is to display the image inside that table...
5
by: john_williams_800 | last post by:
Hi; I am just starting to use the DOM to do some more advanced javascripting so please be patient with my question if it is an ignorant question. I would like to use the DOM to dynamically...
1
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say...
0
by: Thomas Scheiderich | last post by:
I have a table that has 3 image slices. The middle slice changes size based on size of browser window. This works great. My client wants the date to show over the image on the right. So what I...
4
by: Bruce | last post by:
I have an asp.net page that is dynamically building a table and populating cells with images (typically jpeg) and with associated metadata. How can the asp.net code efficiently determine the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.