Preliminary to static variables
by Matthew Day
HTML
<div class="the-box">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>
<div id="the-response" class="the-answer"></div>
CSS
.the-box {
border: 1px solid gray;
float: left;
height: 100px;
padding: 10px 18px;
overflow: hidden;
width: 200px;
}
.the-box.active {
color: red;
height: 398px;
}
.the-answer {
border: 1px solid gray;
float: left;
height: 50px;
margin-left: 50px;
text-align: center;
width: 100px;
}
JavaScript
// 7 April 2016; this is unfinished but it is preliminary to learning how to create a static variable and/or figure out how to keep the value of the collapsed height (when overflow is hidden) so that I can tell jQuery what height it needs to collapse to.
var naturalHeight = $('.the-box').prop('scrollHeight');
var forcedHeight = $('.the-box').height();
var theAnswer = document.getElementById('the-response');
$('.the-box').click(function() {
$(this).toggleClass('active');
//$(this).css('height', naturalHeight);
});
$('.the-answer').click(function() {
theAnswer.innerHTML = forcedHeight;
});