I am a JavaScript newbie and I am attempting to create a basic hide and show div toggle, but unfortunately, it is not functioning properly. I cannot seem to pinpoint the issue – initially, I set the div's display to none
, then when the course-info-toggle
class is clicked, it should change to display:block
with a transition downwards.
Do you have any suggestions?
/* Toggle on course detail sections */
$(document).ready(function() {
$('.course-info-toggle').click(function() {
$('.toggle-content').toggleClass('.show');
});
});
.toggle-content.show {
display: block;
transition: left 0.3s linear;
}
.toggle-content {
display: none;
background-color: #eeeeee;
padding: 1rem;
margin-right: 1rem;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="toggle-wrap">
<div class="course-info-toggle">
<p id="course-details-toggle-font">COURSE OBJECTIVES</p>
<img src="img/course-down-arrow.png" align="course-down-arrow">
</div>
<div class="toggle-content">
<p> 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”<br>
<p> 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”<br>
</p>
</div>
</div>