Return to Snippet

Revision: 35171
at November 3, 2010 18:53 by chopbust


Initial Code
//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'); 
		}
	}
}

Initial URL

                                

Initial Description
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.

Initial Title
Highlight Table Row by Clicking on the Row

Initial Tags

                                

Initial Language
JavaScript