Link to home
Start Free TrialLog in
Avatar of pyc42
pyc42

asked on

onClick event for a <tr> table element in Firefox/Mozilla .... not working. IE does.

As far as i know, firefox/mozilla (in contrary to IE) does not support onClick event on the <tr> table element, so the only way to simulate it is that each row of table acts as one <div>, which reacts to onClick...  It's fairly complicated to implement, is there any better solution to this?

Greetings,
Marko
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pyc42
pyc42

ASKER

okay you're right, and i really misunderstood some piece of code i had recently (not havin' it right now, but i'll upload it asap)... it's actually a part of the question...
Avatar of pyc42

ASKER

<html>
<head>
<script type="text/javascript">
function swapBG(obj)
{
var colour;
colour=(obj.style.background==obj.id) ? "green" : obj.id;
obj.style.background=colour;
}
</script>
</head>

<body>
<table cellspacing="1" border="1">
<tr style="background:red;" id="red" onclick="swapBG(this);">
<td width="200" height="20"></td><td width="200"></td><td width="200"></td>
</tr>
<tr style="background:orange;" id="orange" onclick="swapBG(this)">
<td width="200" height="20"></td><td width="200"></td><td width="200"></td>
</tr>
<tr style="background:yellow;" id="yellow" onclick="swapBG(this)">
<td width="200" height="20"></td><td width="200"></td><td width="200"></td>
</tr>
</table>
</body>
</html>


...... colour=(obj.style.background==obj.id) ? "green" : obj.id;     this line is not working in Firefox, that was my problem.