/ 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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//data_table is the class of the table document.onload = $$('.data_table tr ').each(function(e){ highlight_row(e); } ); //css class 'highlight' is the css code that contains the highlighted background color etc. function highlight_row(e) { e.onclick = function() { class_list = e.className; //alert(class_list.search(/highlight/i)); if (class_list.search(/highlight/i) > -1) { e.removeClassName('highlight'); } else { e.addClassName('highlight'); } } }