469,325 Members | 1,524 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,325 developers. It's quick & easy.

How to add a event to a TR dynamicly created

here i created a TR element using document.createElement("TR");example :
oRow = document.createElemet("TR");
and then i added a attribute "style" on it :
oRow.style.cursor="pointer"; //it does work! But ... have a look at this one :
oRow.onmouseover="this.style.backgroundColor='#ced 6de';" ; //it doesn't work well.
anybody can help me ?
Nov 27 '07 #1
1 922
16,027 Expert Mod 8TB
Put the statement into a function, e.g.
Expand|Select|Wrap|Line Numbers
  1. function setBG() {
  2. this.style.backgroundColor='#ced6de';
  3. }
and then set onmouseover to setBG:
Expand|Select|Wrap|Line Numbers
  1. oRow.onmouseover= setBG;
Nov 27 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.