Results 1 to 3 of 3

Thread: Highlight Table Row script using CSS

  1. #1
    Join Date
    Dec 2005
    Location
    Southern California
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Highlight Table Row script using CSS

    I am using your wonderful script, and I love it!
    but.... I would like to know if I can change the color using css or in my global js file. I tried but so far have not had any luck.
    http://www.dynamicdrive.com/dynamici...lighttable.htm

    <table onMouseover="changeto(event, 'ffcc64')" onMouseout="changeback(event, 'white')">

    Thanks for any advise!
    Jan

  2. #2
    Join Date
    Dec 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    try this:

    Code:
    onmouseover="style.backgroundColor='#333333'; style.cursor='hand'; style.border='1 solid #CCCCCC'" onmouseout="style.backgroundColor='#000000'; style.border='1 solid black';"

  3. #3
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    =gingerj]try this:
    No, don't.

    onmouseover="style.backgroundColor='#333333';
    What style variable would that be referring to, then? Relying on the browser to randomly augment the scope chain is a bad idea. Use the this operator to refer to the element:

    Code:
    this.style.backgroundColor = '...';
    style.cursor='hand';
    There is no 'hand' value for cursors. You mean pointer.

    style.border='1 solid #CCCCCC'"
    A border width of 1 what? Miles? Sheep? All non-zero length values must be followed by a unit.


    As for the original question, the script doesn't consider a style sheet, so that option isn't possible (without a complete rewrite). You could define a global variable containing the colour value, and then reference that when calling the functions:

    Code:
    var highlightColour = '#ffcc64',
        normalColour = '#ffffff';
    then:

    HTML Code:
    <table onMouseover="changeto(event, highlightColour);" onMouseout="changeback(event, normalColour);">
    Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •