Solved

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

Posted on 2004-09-30
3
3,251 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JavaScript export function not working in IE 15 50
Performance for Office 365 6 46
how can i select 4 29
alert(innerHTML); 7 8
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

774 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