ClientHeight or general logic issue (IE Problems)?

I have the following code:

	var block_height = document.getElementById("container").clientHeight;
	var total = 0;
	var lists = document.getElementsByTagName("ul");
	for(var i = 0; i < lists.length; ++i) {
			var items = lists[i].getElementsByTagName("li");
			for(var j = 0; j < items.length; ++j){

				total += items[j].clientHeight;//having problems...
				if(total > block_height){
					items[j].className = "hidden";

I’m trying to figure out why total is 0 (zero) in IE… What am I doing wrong? The code is meant to take list-items and calculate their total height to compare against its container’s height (not the UL but the containing DIV). If they overload the height (greater than), the list begins hiding those LIs that go beyond the allotted height.

Okay, so this has apparently had twenty-something views which usually means that I’ve explained things poorly. So with that, I’ll try to elaborate…

A DIV with the ID of “container” is the parent of the above UL. For the most part, “container” has a set height (it’s in ems, but the JavaScript above calculates the height of it in accordance to pixels–so whatever the DIV’s ems equate to in pixels is the height of the DIV). If the LI’s total height, which is also calculated into a pixel total, goes beyond the pixel height of the DIV’s height, the responsible LIs have display:none applied to their specific elements. So in other words, only the LI elements that go beyond the container’s height get hidden.

I know some of you probably already knew this from seeing the code above, but I’m just trying to do whatever I can to get help with this because I just can’t seem to understand what it is that I’m dropping the ball on. It works flawlessly in FF, but in IE, it bombs and I think it has something to do with the clientHeight but I’m not positive.

Okay, so after messing with this for awhile I found that using “offsetHeight” during the total variable value assignment seemed to do the trick, but as always, if someone around here has a better idea, please share. :slight_smile: