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
Greetings,
Marko
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<html>
<head>
<script type="text/javascript">
function swapBG(obj)
{
var colour;
colour=(obj.style.backgrou nd==obj.id ) ? "green" : obj.id;
obj.style.background=colou r;
}
</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.backgrou nd==obj.id ) ? "green" : obj.id; this line is not working in Firefox, that was my problem.
<head>
<script type="text/javascript">
function swapBG(obj)
{
var colour;
colour=(obj.style.backgrou
obj.style.background=colou
}
</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;"
<td width="200" height="20"></td><td width="200"></td><td width="200"></td>
</tr>
<tr style="background:yellow;"
<td width="200" height="20"></td><td width="200"></td><td width="200"></td>
</tr>
</table>
</body>
</html>
...... colour=(obj.style.backgrou
ASKER