How to add a event to a TR dynamicly created

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • michaelscript
    New Member
    • Nov 2007
    • 9

    How to add a event to a TR dynamicly created

    Hi,
    here i created a TR element using document.create Element("TR");e xample :
    oRow = document.create Elemet("TR");
    and then i added a attribute "style" on it :
    oRow.style.curs or="pointer"; //it does work! But ... have a look at this one :
    oRow.onmouseove r="this.style.b ackgroundColor= '#ced6de';" ; //it doesn't work well.
    anybody can help me ?
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Put the statement into a function, e.g.
    [CODE=javascript]function setBG() {
    this.style.back groundColor='#c ed6de';
    }
    [/CODE]and then set onmouseover to setBG:
    [CODE=javascript]oRow.onmouseove r= setBG;[/CODE]

    Comment

    Working...