Mister Babu Mister Babu - 4 months ago 29
HTML Question

Readmore.js is not working

I recently downloaded readmore.js, but it does not work. I might have forgotten something. The read more button does not appear and the full text is shown.

Here is what I have in the head tag:

<script src="js/jquery-3.1.0.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Readmore.js/2.2.0/readmore.js"></script>


And in the body:

<div class = "article">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ullamcorper sapien eget ante porta eleifend. Aliquam enim velit, suscipit non lorem at, rhoncus sollicitudin arcu. Pellentesque blandit aliquet egestas. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vel nisl magna. Mauris in consequat augue, quis vestibulum augue. Maecenas aliquam scelerisque nunc vitae scelerisque. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam sit amet fermentum arcu. Fusce mollis a augue vel tempus. Etiam aliquet enim et felis congue sodales. Integer sit amet diam nec erat fermentum scelerisque. Phasellus elit sapien, placerat eu mi vitae, convallis pulvinar turpis.
</div>


jquery:

$('.article').readmore();


Thanks in advance.

Answer

Seems your code inside the <script> block is wrong.

You have to make your $('article') either $('#article') or $('.article') (either ID or class selector)

<script>
    $('.article').readmore(); //if you want to use class selector
    $('#article').readmore(); //if you want to use ID selector
</script>

Hope this helps!