Preserved Topic: this.bgColor='#000000' |
|
---|---|
Author | Thread |
Nervous Wreck (II) Inmate From: |
posted 05-03-2004 20:52
does anybody know how to set it so that when someone mousovers a table that bit of the table has a diferent background normally i would use onmousover="this.bgColor='#000000'" but i would not know how to set it up in a script can anyboy help? |
Paranoid (IV) Inmate From: France |
posted 05-03-2004 22:32
EDII: Welcome in the Asylulm, code: <td onmouseover="this.style.backgroundColor="#000000"' onmouseout="this.style.backgroundColor="#ffffff"'>lorem lipsum</td> Otherwise, if you can take the CSS road ( at the cost of leaving aside IE and its lousy support of CSS ), you can simply do : code: <style type="text/css"> And avoid to add some unecessary JavaScript in your structural markup. |
Neurotic (0) Inmate Newly admitted From: |
posted 06-09-2004 17:28
hi there, Im new here.. :) |
Maniac (V) Inmate From: under the bed |
posted 06-09-2004 18:15
Then you will need to set up a function, most likely storing the id's of the td's in an array, and you would call that function with the relevant arguments in the onmouseover=".." bit. |
Nervous Wreck (II) Inmate From: Perth Western Australia |
posted 06-09-2004 19:06
quote:
|
Bipolar (III) Inmate From: Berlin (almost) |
posted 06-09-2004 19:14
I thought this would be the perfect situation in which this.nextSibling and this.previousSibling would come in handy (as they allow you to avoid setting an ID for each and every single TD) and just came up with this function: code: function changeRowColor(cell, color) {
|
Nervous Wreck (II) Inmate From: USA |
posted 06-09-2004 19:20
Is it possible to grab the entire <tr> and background-color that? |
Bipolar (III) Inmate From: Berlin (almost) |
posted 06-09-2004 19:34
D'uh... of course! So much easier this way: code: function changeRowColor(row, color) {
|
Paranoid (IV) Inmate From: France |
posted 06-09-2004 19:38
quote: the time have changed. Now, many web developpers preach for the use of web standards. code: function changeRowColor( cell, color ) But indeed, the suggestion of Iron Wallaby makes perfect sense. |
Bipolar (III) Inmate From: Berlin (almost) |
posted 06-09-2004 19:47
Aaaah I see - thanks for that, poi! |
Neurotic (0) Inmate Newly admitted From: |
posted 06-10-2004 03:14
Thanks a lot! You guys are really nice and helpful :) |