marko krstić

Collections

Archives

Slide toggle with jQuery

Expand object with click on the button.

The trigger is class on the object that will start the animation. Assign the class to the object that should be animated and replace 300 (milliseconds) to what you prefer

$( ".trigger" ).click(function() {
	$( ".toggled-object" ).slideToggle(300);
});

Wrap this with document ready code.

(function($){

    $(function() {

	// Your custom code here
		
    });

})(jQuery);

The final code should look like this

(function($){

    $(function() {

		$( ".trigger" ).click(function() {
			$( ".toggled-object" ).slideToggle(300);
		});
		
    });

})(jQuery);

Let's Connect

Feel free to reach out for collaborations or just a friendly hello 😀
mailme@markokrstic.com
linkedininstagramdribbblefacebook-official