Determine table cell image resides in

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • midwesthills

    #1

    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!!!
  • CarettaCare

    #2
    Re: Determine table cell image resides in

    hi,
    this should work..

    --------------
    <TABLE id="Table1">
    <TR>
    <TD><IMG src="abc.jpg"
    onmouseover="th is.parentElemen t.bgColor='blac k';"></TD>
    </TR>
    </TABLE>
    --------------

    "midwesthil ls" <midwesthills@h otmail.com> wrote in message
    news:1f28b412.0 409201109.22299 93d@posting.goo gle.com...[color=blue]
    > 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!!![/color]


    Comment

    • Randy Webb

      #3
      Re: Determine table cell image resides in

      midwesthills wrote:[color=blue]
      > 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!!![/color]


      <td onmouseover="so mething()" onmouseout="som ethingElse()">. ........</td>

      --
      Randy
      comp.lang.javas cript FAQ - http://jibbering.com/faq

      Comment

      • Michael Winter

        #4
        Re: Determine table cell image resides in

        On Mon, 20 Sep 2004 23:32:04 +0300, CarettaCare
        <carettacareREM OVE@HEREyahoo.c om> wrote:
        [color=blue]
        > this should work..
        >
        > --------------
        > <TABLE id="Table1">
        > <TR>
        > <TD><IMG src="abc.jpg"
        > onmouseover="th is.parentElemen t.bgColor='blac k';"></TD>
        > </TR>
        > </TABLE>
        > --------------[/color]

        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.

        Comment

        Working...