¡@

Home 

2014/10/16 ¤W¤È 12:10:10

jquery Programming Glossary: visibletext

Creating Excerpt text with a read more link

http://stackoverflow.com/questions/1528780/creating-excerpt-text-with-a-read-more-link

lobortis et pretium nibh cursus. p script type text javascript function var textToHide 'p' .text .substring 100 var visibleText 'p' .text .substring 1 100 'p' .html visibleText ' span ' textToHide ' span ' .append ' a id read more title Read More style.. text javascript function var textToHide 'p' .text .substring 100 var visibleText 'p' .text .substring 1 100 'p' .html visibleText ' span ' textToHide ' span ' .append ' a id read more title Read More style display block cursor pointer Read More hellip.. last' .hide 'p span' .hide script So what I've done here is create two variables one to hold the first 100 characters visibleText and one to hold the rest textToHide . We then tell jQuery to find every paragraph tag you'll likely want to define a more..

Using javascript substring() to create a read more link

http://stackoverflow.com/questions/1606336/using-javascript-substring-to-create-a-read-more-link

if text.length 200 var period rest.indexOf '.' var space rest.indexOf ' ' cutoff Math.max Math.min period space 0 var visibleText 'div.contentdetail' .text .substring 0 cutoff 'div.contentdetail' .html visibleText ' span ' rest ' span ' .append ' a title.. Math.min period space 0 var visibleText 'div.contentdetail' .text .substring 0 cutoff 'div.contentdetail' .html visibleText ' span ' rest ' span ' .append ' a title Read More style font weight bold display block cursor pointer Read More hellip..