I have many articles. Article structure as follows
<div class="selected">
<p>[I]some word[/I]</p>
<p>[I]some word[/I]</p>
<p>[I]some word[/I]</p>
<p>[I]some word[/I]</p>
...<!--many p-->
</div>
<div class="selected">
<p>[I]some word[/I]</p>
<p>[I]some word[/I]</p>
<p>[I]some word[/I]</p>
<p>[I]some word[/I]</p>
...<!--many p-->
</div>
...<!--many div.selected-->
Whether jQeury can according to article words, automatically add a toggle function?
I need show the first 3 <p></p> and toggle the rests <p></p>.
I am newer for jQuery, I read some article from jquery.com, and write this one, but lack of something…
jQuery('.selected').find('p:nth(3)').add('<a class="toggle">view more</p>');
$('.toggle').click(function () {
$("p").toggle();
});