开发者

Whether jQuery can according to article words, automatically add a toggle function?

开发者 https://www.devze.com 2023-02-09 05:37 出处:网络
I have many articles. Article structure as follows <p> ___some word___ </p> <p> ___some word___ </p>

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/

0

精彩评论

暂无评论...
验证码 换一张
取 消