Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add mouse event to colgroup or col

Is it possible to add jQuery mouse events on cols or colgroups. We have tried to do so, but it didn't seem to work. On the other hand those cols have a real width and height. Is there a way to make those event work with col?

like image 587
tok Avatar asked Nov 15 '25 08:11

tok


1 Answers

I'm not sure that a colgroup can be given handlers that would react to events over any cell in the group.

You could alternatively give each cell in the group a specific class. Although, if there are a "lot", it wouldn't perform well.

<tr>
  <td class="c1"> column1 </td>
  <td></td>
</tr>

...

cols1 = $(".c1").css('background','#EEE');

Once you get a handle on cols1, keep it until the DOM structure of the table cells change. You won't have to keep iterating the DOM via the selector to get the collection of DOM elements which match.

like image 99
Derrick Avatar answered Nov 18 '25 00:11

Derrick