I am trying my luck at authoring a plugin with jQuery but I am having a few issues. So I want to make this plugin where I take some divs and add a read more or read less link after these divs.
When the read more link is clicked, I want to animate each div’s height to the original height (I say original because the div’s height is shortened before the link is clicked), and set the read more text link to read less – and then the other way around. Similar to the slideToggle effect.
My issue seems to be the “this” keyword, animate() function, or perhaps it is a logic issue… not sure. Here is a link to a live example: http://jsfiddle.net/f978v/
Any help would be much appreciated!
The issue is because of the
ifcondition insidetruncmethod where you check forlinkTxtand decide to increase or reduce the height. Since you are using a local variablelinkTxtto pass the text totruncmethod it is alwaysread more.... I have fixed in the below link, take a lookWorking Demo