jQuery limit the number of elements shown to say like 5
I got lets say this:
<ol>
<li>Content1</li>
<li>Content2</li>
<li>Content3</li>
<li>Content4</li>
<li>Content5</li>
<li>Content6</li>
<li>Content7</li>
<li>Content8</li>
<li>Content9</li>
<li>Content10</li>
<li>Co开发者_开发技巧ntent11</li>
<li>Content12</li>
<li>Content13</li>
</ol>
And the js something like this :
$("li").hide()
$("li:contains('Content')").show()
Qusetion :
Now How can i limit the number of shown elements to lets say around 5 ?
$("ol li:contains('Content')").slice(0, 5).show();
or:
$("ol li:contains('Content'):lt(5)").show();
try this-
$("ol li:contains('Content'):lt(5)").show();
精彩评论