/    Sign up×
Community /Pin to ProfileBookmark

colgroup or col associated even

I am trying to associate events with entire columns in a table, but its not working (with both ‘colgroup’ or ‘col’). If it should/can work, how?

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
http://www.w3.org/TR/html4/strict.dtd“>
<html lang=”en”>
<head>
</head>

<body>
<div >
<table width=”50%”>
<colgroup span=”1″ onmouseover=”javascript:alert(‘SDF’)” />

<tr>
<td> Home1 </td>
</tr>

<tr>
<td> Home2 </td>
</tr>

</table>
</div>
</body>
</html>

to post a comment
HTML

2 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 06.2007 — It should, but support for colgroup/col is patchy in all browsers.

Incidentally the minimized tag syntax is not permitted:Start tag: required, End tag: optional

A JavaScript solution:&lt;script type="text/javascript"&gt;
window.onload=function() {
var aTR=document.getElementById('table1').getElementsByTagName('tr');
for(var i=0; i&lt;aTR.length; i++) {
if (aTR[i].cells[0].addEventListener) { // W3C
aTR[i].cells[0].addEventListener('mouseover', function() {alert('SDF'); }, false);
}
else {
aTR[i].cells[0].attachEvent('onmouseover', function() {alert('SDF'); } );
}
}
}
&lt;/script&gt;
Copy linkTweet thisAlerts:
@WebJoelMay 06.2007 — I don't understand what you're trying to do, but here's something to look at:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">

<head>

</head>

<body>

<div >

<table width="50%" border="1">

<tr>

<th width="50%" span="first onmouseover="javascript:alert('SDF')">First</th>

<th width="50%" span="second" onmouseover="javascript:alert('SDF-2')">Second</th></tr>

<tr>

<td> Home1 </td>

<td> Home2 </td>

</tr>

<tr>

<td> Home3 </td>

<td> Home4 </td>

</tr>


</table>

</div>

</body>

</html>[/QUOTE]
×

Success!

Help @jak123 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...