« 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


So all he had to do was learn some Norse magic.  Free Loki.  Find Liz.  Stop Ragnarok.  Help Sygin get her revenge on the lords of the Æsir.  Defeat the Krim, and get home.
Easy, really.
Jerry, Pyramid Power, Eric Flint & Dave Freer