hsquareweb
3/7/2012 - 3:58 AM

CSS/JS: Table TD Hover For IE

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;
})();
}