FAQ Design with SlideToggle jQuery Function

This is a FAQ Design Example. I am using the SlideToggle() function from jQuery.

This is a FAQ Design Example. I am using the SlideToggle() function from jQuery. This can be helpful to display your FAQ within your websites. I tried to kep the FAQ function as small as possible. 

This is the function that i used to toggle the answers from their questions. 

$( document ).ready(function() {
	$( ".questionLink" ).click(function() {
		var id = $(this).attr('id');
		$( '.' + id +  '').slideToggle( 300);
	});
});

 

The Question and Answer HTML is the following. 

<div class="faqElements">
	<div class="question"><a href="#" id="question4" class="questionLink">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod?</a></div>
	<div class="answer question4">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
	tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
	quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
	consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
	cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
	proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>

 

View Demo