Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
angular2 2 way binding on load 7 39
Replace &lt; with < 14 56
Why my select dropdown does not work? 8 27
Removing HTML elements using javascript 4 20
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now