|
-
Oct 28th, 2004, 12:51 PM
#1
Thread Starter
Member
[Resolved] How to change table row color with JavaScript
Hi, all,
I have a question about javasrcipt. The following HTML page has a table composed of three rows. I wish to know how to find the yellow row and change its bgcolor to red? Use javascript.
Thank you very much for any suggestion!
xihu24
Code:
<html>
<script lauguage="javascript">
function findYellowRow(){
// implementation to change the row from yellow to red
// ?
}
</script>
<body>
<table>
<tr bgcolor=white><td>1</td></tr>
<tr bgcolor=yellow><td>2</td></tr>
<tr bgcolor=white><td>3</td></tr>
</table>
<form>
<input type="button" value="FindYellowRow" onClick="findYellowRow();">
</form>
</body>
</html>
Last edited by xihu24; Oct 29th, 2004 at 04:32 PM.
-
Oct 29th, 2004, 01:35 AM
#2
Frenzied Member
I'm in hurry so a quickie:
You could go through each td by first getting the table using an ID (getElementByID) and then look for .bgColor == "yellow"
but it would be easier to do it with classes and stylesheets.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 29th, 2004, 04:32 PM
#3
Thread Starter
Member
Hi, Job,
Thank you very much. getElementByID() works fine.
xihu24
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|