How do you say :
if there are more than 2 .quick_fact then
My attempt:
if $(".quick_fact:gt(2)") { }
Which evidently is always true.
How do you say :
if there are more than 2 .quick_fact then
My attempt:
if $(".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 ) { }