Alternating row colors and adding hover with javascript
Views: 954Keeping in my do-it-all-with-javascript theme, here's something else I created in order to keep the javascript completely separate from the HTML from the more javascript stuff.
It was originally created for the purposes of adding the hover onmouseover, but I also decided to add the alternating row color at the same time.
To be completely anal, I'll note that the hover is something that should be done with javascript (it pretty much has to be done in javascript anyways, and it's less part of the presentation than an action), while the alternating colors should be purely CSS.
However, this makes page creation easier. I also remember having some problems with reading the background color style from the row object, so this makes it easy.
It uses behaviour.
-
function init_hoverclick_list () {
-
var initList = {
-
'tr.hoverclick' :
-
function (el) {
-
el.list_mod = list_iterate++ % 2;
-
el.style.background = list_colors[el.list_mod];
-
-
-
el.onclick = function() {
-
url = document.getElementById(this.id + ':url').innerHTML;
-
location.href = url;
-
},
-
el.onmouseover = function() {
-
this.style.background = list_hover_color;
-
},
-
el.onmouseout = function() {
-
this.style.background = list_colors[el.list_mod];
-
}
-
}
-
};
-
-
Behaviour.register(initList);
-
Behaviour.apply();
-
}
April 3rd, 2007 at 2:33 pm
you should put an example of your script in the blog so people can see what it looks like in action
August 4th, 2007 at 11:08 am
The plan of bonification of Telextreme is fantastic, therefore with few indications you can form a net of distribution of much success and excellent financial return. Visit: www.voipshop.tv
December 5th, 2007 at 8:25 pm
All Internal Girls…
all internal girls…
December 18th, 2007 at 9:59 pm
jenna jameson in action…
jenna jameson in action…
July 4th, 2008 at 4:28 pm
Anal Sex Anal Insertions Anal Sex Videos…
I can not agree with you in 100% regarding some thoughts, but you got good point of view…