Skip to content

Instantly share code, notes, and snippets.

@hsquareweb
Created March 7, 2012 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsquareweb/1990855 to your computer and use it in GitHub Desktop.
Save hsquareweb/1990855 to your computer and use it in GitHub Desktop.
CSS/JS: Table TD Hover For IE
td.hovered {background: #ffdb7f !important; cursor: pointer !important;}
// ********************************************************************
// TABLE TD HOVER FOR IE
// ********************************************************************
if(document.getElementsByTagName) {
(function() {
var className = 'hovered',
pattern = new RegExp('(^|\\s+)' + className + '(\\s+|$)'),
//Replace this:document.getElementsByTagName('tr');with this:document.getElementById('id_of_your_table').getElementsByTagName('tr'); to restrict to a particular table.
rows = document.getElementsByTagName('td');
for(var i = 0, n = rows.length; i < n; ++i) {
rows[i].onmouseover = function() {
this.className += ' ' + className;
};
rows[i].onmouseout = function() {
this.className = this.className.replace(pattern, ' ');
};
}
rows = null;
})();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment