|
Hi, I want to truncate some text that is comprised of a number of paragraphs. It should be possible to see the text that has been truncated by clicking on something like "read more..." . The text should then fade in and it should be possible to click the text away again by clicking "...read less". There are a number of jquery plugins available but each one has a different problem:
Please please can someone suggest a way forward for me! It would be much appreciated.. |
|
I have come up with a solution which although not perfect, does work. The solution is simply to split the paragraphs over two divs. The first div contains the text you wish to be visible all the time and the second div contains the text // paragraphs you to become visible on clicking a button the says "view more" or whatever. Then it's just a case of using a simple bit of javascript to fade in the second div when the button is clicked. the function:
The div that is made visible by clicking #btnMore1 is called #expander1 above. If you place another button within a div called #btnLess and then place that div within the div that is made visible (#expander1), call it something like "view less" then it will only be seen when the #expander 1 div is visible. Click it and the text will fade out again. I should also point out that I found away of adding a fade function to the Truncator (no. 4 in the above post) plugin. It is technique mentioned in the comments on it's webpage bu unfortunately it fades the entire text in / out rather then just the truncated text so it doesn't look great. Hope this helps someone! |



