Hello, started learning jquery. I write the first plug-in "Read more", that is, I want the block initially to be 15px high, and when I click on the link, the animation block opens completely, and when I press the button again, the block collapses.
This is what I came to (I ask you not to shout that the stash, etc.)
<script type="text/javascript"> $(document).ready(function(){ $('#show_more').toggle( function(){ $("#show_desc").animate({ height: auto }, 500 ); $('#show_more').text('Свернуть'); }, function(){ $("#show_desc").animate({ height: '15px' }, 500 ); $('#show_more').text('Читать далее'); } ) }); </script> <a href="#" id="show_more">Свернуть</a> <div id="show_desc" style="height: 15px;">text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text </div> But something is somehow wrong :) Glad to hear your options or amendments.