Posted By

chopbust on 11/03/10


Tagged

prototype highlight row Scriptaculous


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Highlight Table Row by Clicking on the Row


 / Published in: JavaScript
 

This is a snippet to highlight the clicked row. The code is in Prototype library format. I am yet to port this into JQuery, but please do email me if you already did.

  1. //data_table is the class of the table
  2. document.onload = $$('.data_table tr ').each(function(e){ highlight_row(e); } );
  3.  
  4.  
  5. //css class 'highlight' is the css code that contains the highlighted background color etc.
  6. function highlight_row(e) {
  7.  
  8. e.onclick = function() {
  9. class_list = e.className;
  10. //alert(class_list.search(/highlight/i));
  11. if (class_list.search(/highlight/i) > -1) {
  12. e.removeClassName('highlight');
  13. } else {
  14. e.addClassName('highlight');
  15. }
  16. }
  17. }

Report this snippet  

You need to login to post a comment.