Skip to content

Instantly share code, notes, and snippets.

View stefaneg's full-sized avatar

Guðlaugur Stefán Egilsson stefaneg

View GitHub Profile
@stefaneg
stefaneg / app.js
Created October 2, 2013 11:56
AngularJS add class to table header on cell hover. Add this directive to td being rendered in order to get class set on the corresponding td in thead section of the table.
.directive('addClassToHeaderOnHover', function(){
return function(scope, element, attrs){
var classname = element.attr('add-class-to-header-on-hover');
element.mouseenter(function(){
var idx = element.index() + 1;
var $htd = element.parents('table').find('thead td:nth-child(' + idx + ')');
$htd.addClass(classname);
});
element.mouseleave(function(){