jQuery UI Accordion Options HeightStyle

ExampleJquery ui accordion options heightstyle
Source Code Expand
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript" src="http://www.pureexample.com/js/lib/jquery.ui.touch-punch.min.js"></script>


<!-- CSS -->
<style type="text/css">
#accordion {
    font-size: 50%;
}
</style>


<!-- Javascript -->
<script>
$(function () {
	$("#accordion").accordion({
		heightStyle: "content"
	});

	$("input").each(function () {
		$(this).change(function () {
			if ($(this).attr("id") == "1") {
				$("#accordion").accordion("option", "heightStyle", "fill");
			} else if ($(this).attr("id") == "2") {
				$("#accordion").accordion("option", "heightStyle", "auto");
			} else if ($(this).attr("id") == "3") {
				$("#accordion").accordion("option", "heightStyle", "content");
			}

			$("#accordion").accordion("refresh");
		});
	});
});
</script>

<!-- HTML -->
<div>Selector for the header element</div>
<div style="height:250px">
    <div id="accordion">
         <h3>Tab 1 </h3>
        <div>Tab 1 content
            <br>Tab 1 content
            <br>Tab 1 content
            <br>Tab 1 content
            <br>Tab 1 content
            <br>Tab 1 content
            <br>
        </div>
         <h3>Tab 2 </h3>
        <div>Tab 2 content
            <br>Tab 2 content</div>
         <h3>Tab 3 </h3>
        <div>Tab 3 content</div>
    </div>
</div>
<div style="margin-top:40px">
    <input type="radio" name="options" id="1">heightStyle:fill
    <input type="radio" name="options" id="2">heightStyle:auto
    <input type="radio" name="options" id="3" checked>heightStyle:content</div>


comments powered by Disqus