Solved

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

Posted on 2004-09-30
3
3,267 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:pyc42
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 250 total points
ID: 12189333
This works for me in Mozilla1.7.2:

<html>
<body>
<table>
<tr onClick="alert('Hello')"><td>Click me</td></tr>
</table>
</body>
</html>

0
 

Author Comment

by:pyc42
ID: 12189456
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...
0
 

Author Comment

by:pyc42
ID: 12190261
<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.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question