You can use the greater-than/less-than selectors:
$("#someDiv p:lt(4)").hide(); /* hides 0, 1, 2, 3 */
That would hide all paragraphs less than the fifth. To determine whether or not there's 5 or more paragraphs, you'll check the length property:
if ($("#someDiv p").length > 5) {
$("#someDiv p:gt(3)").hide(); /* hides 4, 5, 6... */
}
Jonathan Sampson
2009-07-10 11:32:19