jquery show hide, numerous divs lag problem
I have a rather extensive list of titles and definitions to which I have a show/hide effect applied to. Im assuming from the sheer amount of text and items, the speed at which this occurs is almost painful. I originally used code from another source, so it's not my work. I do know that the "read more" link that triggers the effect is set to come in after the page loads… this could be another reason for my issue. Im not entirely sure that it needs to be structured that way but I am a novice here and can only rely on logic for my current troubleshooting methods. Any help, as always, is greatly appreciated.


THE SCRIPT

    ` $(function(){
        var slideHeight = 36; // px
         $('.jswrap').each(function(){
            var defHeight = $(this).height();
            if(defHeight >= slideHeight){
                $(this).css({'height':slideHeight,'max-height': defHeight});
                $(this).after($('<div class="jsreadmore"><a href="#">Read More</a></div>'));
            }
             
            $('.jsreadmore a').click(function(){
                var $targetSlide = $(this).parent().prev(),
                    curHeight = $targetSlide.height(),
                    defHeight = $targetSlide.css('max-height');
                if(curHeight == slideHeight){
                    $targetSlide.animate({
                      height: defHeight
                    }, "normal");
                    $targetSlide.next().children('a').html('Close');
                }else{
                    $targetSlide.animate({
                      height: slideHeight
                    }, "normal");
                    $targetSlide.next().children('a').html('Read More');
                }
                return false;
            });
        });
     });

THE HTML

     <div class="jscontainer">
        <h4>Other Procedures</h4>
    	    <div class="jswrap">
    		<p>content</p>
                <p>more content</p>
                <p>more content</p>
    	</div></div>






`

THE CSS

    .content_sub1 .jscontainer {margin:0 auto;}
    .content_sub1 .jscontainer h2 {font-size:20px;color:#0087f1;}
    .content_sub1 .jswrap {position:relative; padding:10px; overflow:hidden;}
    .content_sub1 .jsgradient {width:100%;height:35px; position:absolute; bottom:0; left:0;}
    .content_sub1 .jsreadmore {padding:5px; color:#333; text-align:right;}
    .content_sub1 .jsreadmore a {padding-right:22px; font-weight:bold; font-size:12px; text-transform: uppercase; color:#c44;  font-family:arial, sans-serif;}
    .content_sub1 .jsreadmore a:hover {color:#000;}



LINK TO THE PAGE

http://www.doctorhtiller.com/procedures.html

jquery show hide, numerous divs lag problem
===

I have a rather extensive list of titles and definitions to which I have a show/hide effect applied to. Im assuming from the sheer amount of text and items, the speed at which this occurs is almost painful. I originally used code from another source, so it's not my work. I do know that the "read more" link that triggers the effect is set to come in after the page loads… this could be another reason for my issue. Im not entirely sure that it needs to be structured that way but I am a novice here and can only rely on logic for my current troubleshooting methods. Any help, as always, is greatly appreciated.


THE SCRIPT

    ` $(function(){
        var slideHeight = 36; // px
         $('.jswrap').each(function(){
            var defHeight = $(this).height();
            if(defHeight >= slideHeight){
                $(this).css({'height':slideHeight,'max-height': defHeight});
                $(this).after($('<div class="jsreadmore"><a href="#">Read More</a></div>'));
            }
             
            $('.jsreadmore a').click(function(){
                var $targetSlide = $(this).parent().prev(),
                    curHeight = $targetSlide.height(),
                    defHeight = $targetSlide.css('max-height');
                if(curHeight == slideHeight){
                    $targetSlide.animate({
                      height: defHeight
                    }, "normal");
                    $targetSlide.next().children('a').html('Close');
                }else{
                    $targetSlide.animate({
                      height: slideHeight
                    }, "normal");
                    $targetSlide.next().children('a').html('Read More');
                }
                return false;
            });
        });
     });

THE HTML

     <div class="jscontainer">
        <h4>Other Procedures</h4>
    	    <div class="jswrap">
    		<p>content</p>
                <p>more content</p>
                <p>more content</p>
    	</div></div>






`

THE CSS

    .content_sub1 .jscontainer {margin:0 auto;}
    .content_sub1 .jscontainer h2 {font-size:20px;color:#0087f1;}
    .content_sub1 .jswrap {position:relative; padding:10px; overflow:hidden;}
    .content_sub1 .jsgradient {width:100%;height:35px; position:absolute; bottom:0; left:0;}
    .content_sub1 .jsreadmore {padding:5px; color:#333; text-align:right;}
    .content_sub1 .jsreadmore a {padding-right:22px; font-weight:bold; font-size:12px; text-transform: uppercase; color:#c44;  font-family:arial, sans-serif;}
    .content_sub1 .jsreadmore a:hover {color:#000;}



LINK TO THE PAGE

http://www.doctorhtiller.com/procedures.html
