« Blog Home

§ Table row hover highlight

A bit of javascript to highlight the table row under the cursor.

 


function removeName(el, name) {
  //don't waste time
  if(el.className.indexOf(name)<0)
    return;
  var i, curList, newList;
  // Remove the given class name from the element's className property.
  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}
function trMouseover() {
  this.className+=' resultrowhighlight';
}
function trMouseout() {
  removeName(this,'resultrowhighlight');
}
function addTrMouseEvents() {
  var trlist=document.getElementsByTagName("tr");
  for(var i=0;i<trlist.length;i++) {
    if(trlist[i].className.indexOf('resultrow')>-1) {
      trlist[i].onmouseover=trMouseover;
      trlist[i].onmouseout=trMouseout;
    }
  }
}
function makeDoubleDelegate(function1, function2) {
  return function() {
    if (function1)
      function1();
    if (function2)
      function2();
  }
}
window.onload = makeDoubleDelegate(window.onload, addTrMouseEvents );
 

 

last edited on January 29th, 2009 at 1:33 PM

Comments

No Comments Here. Add yours below!

Add your comment

Name:
Email: (Will not be displayed - Privacy policy)
Website:
Comments:
  random image I can't read it!
Give me a different one!
Verify Post: Input the text from the image above to verify this post (helps prevent spam)
 

« Blog Home

Comments

Oppuk gazed down at the creature in disgust.  Not only had it forced its barbaric name upon him, it smelled of floral aromatics, which the denizens of this world often applied to themselves in the mistaken belief that the natural scents of their bodies were noisome, while blatant artificial odors were somehow more acceptable.
Oppuk, The Course of Empire, Eric Flint & K.D. Wentworth