This code should works as it retrieves the parent height during run- time $(document).ready(function() { var cnt1 = $("#test_list").parent().css("height"); var cnt2 = $("#test_list").children(":first").css ("height");
var re = /px/g; alert(parseFloat(cnt1.replace(re, "")) / parseFloat (cnt2.replace(re, ""))); //five $("#test_list").parent().css("height", "120px"); cnt1 = $("#test_list").parent().css("height"); alert(parseFloat(cnt1.replace(re, "")) / parseFloat (cnt2.replace(re, ""))); // six }); On Nov 15, 1:35 am, gravyfries <chuckco...@gmail.com> wrote: > Any idea how to make this work? In the following example I need to > know how many items fall inside/outside of the visible area. This > can't be based on the height of the parent div because that will be > variable eventually: > > <html> > <head> > <title></title> > <script type="text/javascript" src="jquery-1.3.2.js"></script> > <script type="text/javascript"> > $(document).ready(function(){ > var cnt = $('#test_list li:visible').size(); > alert(cnt); > }); > </script> > <style> > ul, li {padding: 0; margin: 0;} > li {height: 20px;} > </style> > </head> > <body> > > <div style="height: 100px; overflow: hidden;"> > <ul id="test_list"> > <li>Test</li> > <li>Test</li> > <li>Test</li> > <li>Test</li> > <li>Test</li> > <li>Test</li> > <li>Test</li> > <li>Test</li> > <li>Test</li> > <li>Test</li> > <li>Test</li> > <li>Test</li> > </ul> > </div> > > </body> > </html>