Do I need a loop?

Do I need a loop?

I am creating a one page WordPress website and I am having trouble with some jquery. I have several pages and maybe several more that need to have a custom scrollbar on the page. I have the scrollbar working great. All I have to do is create a div, give it the class of scroll and I am in business. My problem is that if a new page is created and the content of that page isn't greater than the default height of the div which is 400px, then the scrollbar still shows on the page. So I thought I would use a little jquery to get rid of the scrollbar. I tried doing this

  1. var divh = $('.height').height();
            if(divh > 400){
                $('.height').wrap("<div class='scroll'></div>");
            }


So I need to get every div that has a class of "height" ( There could be many on one page) and test it to see if it's greater than 400. If so, wrap the contents of the div with the class. I can see that this works just fine on one page. I have tested by removing the jquery and the scrollbar goes away. So I know the code works. The problem is that on other pages that are part of the "One page system", the scrollbar doesn't show. So I went searching for a solution and found the each() function. Problem is that ever time I add the each() into the code, the jquery crashes. It's probably crashing because I am doing it wrong. 


So how can I test for every element with the class of "height" and wrap it if it is greater than 400 without crashing the code?