Wednesday, 21 August 2013

How do I show an element using the below JQuery code?

How do I show an element using the below JQuery code?

CODE:
$(document).ready(function() {
$('.clicker').on('click', function(e){
e.preventDefault();
var $btn = $(this);
$btn.toggleClass('opened');
var heights = $btn.hasClass('opened') ? 300 : 100 ;
$('#thiswillexpand').stop().animate({height: heights });
});
});
By default I want #thiswillexpand to be hidden so I am going to use
display:none; But when .clicker is clicked I want it to show and then
expand as the script is supposed to.
Question:
How do I show #thiswillexpand when .clicker is clicked while still
retaining whatever the script is doing?

No comments:

Post a Comment