168
rated 0 times
[
173]
[
5]
/ answers: 1 / hits: 83571
/ 12 Years ago, sun, january 13, 2013, 12:00:00
I have a link and a table row that have matching classes. When the link is clicked, I would like to change the background color of the row with the same class. For each case, there will be only one row with the same class.
Here is my current function.
<script type=text/javascript>
function check(x) {
elements = document.getElementsByClassName(x);
for (var i = 0; i < elements.length; i++) {
elements[i].bgColor=blue;
}
}
</script>
Here is a part of the table row script:
<tr class=alt1 12>
<td width=50 height=55>
<img src=iPhone/statusicon/12.png alt= id=forum_statusicon_12 border=0></td>
<td>
<div class=forumtitle>
<a class=forumtitle 12 href=forumdisplay.php?f=12 action=async onclick=check(this.className.split(' ')[1])>News and Current Events</a></div>
</td>
<td width=25>
<div class=forumarrow><img src=iPhone/chevron.png alt= border=0></div>
</td>
</tr>
The table row has two classes, and I need the second one (the number) to be what is addressed. The current code gives the error An invalid or illegal string was specified
More From » html