How do you say :
if there are more than 2 .quick_fact then
My attempt:
if $开发者_JAVA百科(".quick_fact:gt(2)") { }
Which evidently is always true.
A jQuery object has a length
property representing the number of matched elements. So simply do a typical "greater than" comparison.
if( $('.quick_fact').length > 2 ) {
// There were more than two
}
if ($(".quick_fact").size() > 2 ) { }
Or:
if ($(".quick_fact").length > 2 ) { }
精彩评论