jQuery Simple Accordion

Click This

example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text

Click This

example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text

Click This

example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text example text

JSソースコード

<script type="text/javascript">
$(function()
{
	$("div#simpleAccordion div").hide();
	$("div#simpleAccordion h2").each(function()
	{
		var elementVal = $(this).next("div");
		$(this).click(function()
		{
			elementVal.slideToggle("normal");
		});
	});
});
</script>

HTMLソースコード

<div id="simpleAccordion">
<h1>jQuery Simple Accordion</h1>
<h2>Click This</h2>
<div>
<p>example text example text example text example text</p>
</div>
<h2>Click This</h2>
<div>
<p>example text example text example text example text</p>
</div>
<h2>Click This</h2>
<div>
<p>example text example text example text example text</p>
</div>
<!-- // end #myAco --></div>

ブログ記事に戻る