Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKristian Woods
23,414 PointsWhy is the slideToggle JQuery function not working for me?
I'm trying to change the display mode of a div containing images - when the user clicks the button, the div displays the images. I heard that the slideToggle function works great for that. But it doesn't work when I use it. Any thoughts as to why?
<div class="showMoreContainer">
<a href="#" id="showHideBtn">Show More</a>
</div>
<div id="hiddenImages">
<div class="carousel_image">
<div class="mobile_overlay">
<h3>Glasgow Cathedral</h3>
<a href="#" class="more_info_link">More info</a>
</div>
<img src="img/ggow_cath.jpg" alt="Glasgow Cathedral" title="Glasgow Cathedral">
</div>
<div class="carousel_image">
<div class="mobile_overlay">
<h3>Tea Room</h3>
<a href="#" class="more_info_link">More info</a>
</div>
<img src="img/tea_room.jpg" alt=" cup of tea" title="Tea room" class="tea_room_img">
</div>
<div class="carousel_image">
<div class="mobile_overlay">
<h3>Kelvin Museum</h3>
<a href="#" class="more_info_link">More info</a>
</div>
<img src="img/kelvin.jpg" alt="Kelvin_museum" title="Kelvin_museum" class="kelvin_img">
</div>
</div>
I use a class of 'hidden' to hide the images at first
.hidden {
display: none;
}
$('#showHideBtn').click(function(e) {
e.preventDefault();
$('#hiddenImages').slideToggle();
});
2 Answers
Aymen Hachicha
12,653 PointsCan you upload your entire project??
Kristian Woods
23,414 PointsI seem to be unable to post my entire project. I don't have any other javascript within the project, though. Could it be CSS?
Kristian Woods
23,414 Pointsok, problem was the CDN I had installed - fixed it. Thank you for your help though
Danielle Rivers
353 PointsKristen Woods, thank you for that find. I had the same issue and it was driving me nuts. I basically chose the minified version over the slim version in code.jquery.com and it fixed everything.
izzy goldman
12,542 Pointsizzy goldman
12,542 PointsYour styles aren't working cos You Dont have a class name '.hidden'!