Actually, it's all about if-else.
Let me explain it to you.
<div id="parent">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
</div>
to reach the count of children, you should use .length like this;
var count = $("#parent li").length;
or this way
var count = $("#parent ul").children().length;
Now let's say you want to execute if the count of children is bigger than 2 or whatever you want;
if(count>2){
alert("I am bigger than 2, mate");
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…