Whether jQuery can according to article words, automatically add a toggle function?
I have many articles. Article structure as follows
<p> ___some word___ </p>
<p> ___some word___ </p>
<p> ___some word___ </p>
<p> ___some word___ </p>
...
Whether jQuery can according to article words, automatical开发者_如何学JAVAly add a toggle function?
I need: show first 100 words and toggle the rests OR show the first 3<p></p>
and toggle the rests.
Thanks.
$('p:contains("some word")').toggle(function(){
//do something
});
More info on the :contains selector at http://api.jquery.com/contains-selector/
精彩评论