PiotrS PiotrS - 5 months ago 32
HTML Question

Show div after substring() text

var x= $('div.text').text();
var first15=x.substring(0, 55);

if ($(".text").html(first15).length == 55) {


border:1px solid #000;
overflow: hidden;


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="text">.Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).

<div class="ShowText">Show more...</div>

Is possible to show() class="ShowText" only when text has 55 characters?
But when I add "=" always show "ShowText"

Thanks for answer


just use this one

(first15.length == 55)

because length


here length is jquery method which will return the number of elements in that element which is 1. so 1 is not equal to 55 .