PiotrS PiotrS - 8 days ago 5
Javascript Question

Show more text in PopUp window



$('.SeeMore').click(function() {
$('.PopUp').fadeIn(10).html('.text')
});

.text
{
width:200px;
height:200px;
border:1px solid #000;
background-color:rgba(230,230,230,1);
overflow:hidden;
position:relative;
}
.SeeMore
{
position:absolute;
bottom:0;
right:0;
display:none;
}

.PopUp
{
width:300px;
height:300px;
background-color:white;
border:1px solid #000;
position:absolute;
top:0;
left:0;
display:none;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

<div class="SeeMore">Show more
</div>




</div>

<div class="PopUp">
</div>





Hello,
I have two questions, first how make if text is bigger than div size in bottom-right corner show text "Show more" and next click on this and show all text in pop up window?

Answer

You can use JS to count how many characters there are in the text, and if it exceeds the div's amount, then show the "show more" button. Then, you can use window.open to open a popup. See this fiddle