How to set read more button using data from database in php
<p>Actually I'm using <code>laravel</code> framework.In which I use certain queries and methods to retrieve data from database..</p>

<p>And its my code below</p>

<pre><code>&lt;ul class="booking-list"&gt;
    @foreach($aRooms as $aRoom)
        &lt;li&gt;
        ....
            &lt;div class="comment more"&gt;
                {{$aRoom-&gt;room_desc}}
            &lt;/div&gt;
        ....
        &lt;/li&gt;
    @endforeach
&lt;/ul&gt;
</code></pre>

<p>There are many contents to display like <code>{{$aRoom-&gt;room_desc}}</code>.But by using this <code>{{$aRoom-&gt;room_desc}}</code> I have to set the <code>Read more</code> <code>Read less</code> toggle option.</p>

<p>I don't know how to set that using jQuery,if the data is from database</p>

<p>And here is my jQuery,</p>

<pre><code>&lt;script&gt;
$(document).ready(function() {
    var showChar = 100;
    var ellipsestext = "...";
    var moretext = "More (+)";
    var lesstext = "Less (-)";
    $('.more').each(function() {
        var content = $(this).html();

        if(content.length &gt; showChar) {

            var c = content.substr(0, showChar);
            var h = content.substr(showChar-1, content.length - showChar);

            var html = c + '&lt;span class="moreelipses"&gt;'+ellipsestext+'&lt;/span&gt;&amp;nbsp;&lt;span class="morecontent"&gt;&lt;span&gt;' + h + '&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;a href="" class="morelink"&gt;'+moretext+'&lt;/a&gt;&lt;/span&gt;';

            $(this).html(html);
        }

    });

    $(".morelink").click(function(){
        if($(this).hasClass("less")) {
            $(this).removeClass("less");
            $(this).html(moretext);
        } else {
            $(this).addClass("less");
            $(this).html(lesstext);
        }
        $(this).parent().prev().toggle();
        $(this).prev().toggle();
        return false;
    });
});
&lt;/script&gt;
</code></pre>

<p>Thanks,</p>