I am looking to add an expander/truncator feature to a site I'm
building. However, the plugins and other code snippets I've found cut
off text based on character count. What I'm looking for is something
that cuts off based on a specific number of paragraphs. So, for
example, inside a targeted div, after the second <p> it would hide all
remaining <p>s, and insert a "read more" link. Clicking would expose
the hidden elements and add a "read less" link.

I haven't been able to figure out a way to do this... Can anyone point
me in the right direction? I've posted an example page here:

http://www.cement-site.com/truncator/example.shtml

It's making use of the truncator plugin found here:
http://henrik.nyh.se/2008/02/jquery-html-truncate

(I've also tried Karl Swedberg's Expander plugin, but it doesn't seem
appropriate in this case since it's not intended to truncate/expand
across multiple block-level elements.)

Can this truncator plugin code be modified to count <p>s rather than
characters? Or is there a simpler/better way to accomplish this?

Thanks!

Reply via email to