Note that there are some explanatory texts on larger screens.

plurals
  1. POPerformance issue show/hide multiple divs
    primarykey
    data
    text
    <p>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.</p> <p>THE SCRIPT</p> <pre><code>$(function(){ var slideHeight = 36; // px $('.jswrap').each(function(){ var defHeight = $(this).height(); if(defHeight &gt;= slideHeight){ $(this).css({'height':slideHeight,'max-height': defHeight}); $(this).after($('&lt;div class="jsreadmore"&gt;&lt;a href="#"&gt;Read More&lt;/a&gt;&lt;/div&gt;')); } $('.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; }); }); }); </code></pre> <p>THE HTML</p> <pre><code> &lt;div class="jscontainer"&gt; &lt;h4&gt;Other Procedures&lt;/h4&gt; &lt;div class="jswrap"&gt; &lt;p&gt;content&lt;/p&gt; &lt;p&gt;more content&lt;/p&gt; &lt;p&gt;more content&lt;/p&gt; &lt;/div&gt;&lt;/div&gt; </code></pre> <p>`</p> <p>THE CSS</p> <pre><code>.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;} </code></pre> <p>LINK TO THE PAGE</p> <p><a href="http://www.doctorhtiller.com/procedures.html" rel="nofollow">http://www.doctorhtiller.com/procedures.html</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload