JS Help Pls
- Started
- Last post
- 2 Responses
- mikeim
I am using this script I found to alternate styles in a comment li but it's returning an error warnings in IE, can anyone see the issue:
var commonJS = {
addEvent: function(obj,type,fn) {
if (obj.addEventListener) {
obj.addEventListener(type,fn,fal...
return true;
} else if (obj.attachEvent) {
obj['e'+type+fn] = fn;
obj[type+fn] = function() { obj['e'+type+fn]( window.event );}
var r = obj.attachEvent('on'+type, obj[type+fn]);
return r;
} else {
obj['on'+type] = fn;
return true;
}},
stripe: function(tbIndex) {
var tRows = document.getElementById('comment...
// var i=0 for odd rows
// var i=1 for even rows
for (var i=0, thisRow; thisRow=tRows[i]; i+=2) { // increment by 2
thisRow.className += (thisRow.className) ? ' even' : 'even';
}}
}
commonJS.addEvent(window,'load...
- acescence0
hard to say, your js is getting a bit chopped. event listeners are tough in IE, i usually use jQuery for stuff like this as it's dead simple and lets you do all sorts of stuff without worrying about onload conflicts and browser differences. something like that is as simple as:
$("ul.yourUl li:even").addClass("evenrow");