English | 正體中文 | 简体中文

Jquery ui accordion options disabled



范例程式码 Expand
<!-- Javascript -->
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css"></link>
<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>
    $(function () {
        $("#accordion").accordion({
            heightStyle: "fill",
            disabled: true 
        });
        
        $("input").each(function(){
            $(this).change(function(){
                if($(this).attr("id") == "disableaccordion"){
                	$("#accordion").accordion("option","disabled", true);    
                }else{
                    $("#accordion").accordion("option","disabled", false);    
                }
            	
            });
        });
    });
</script>

<!-- HTML -->
<style>
    #accordion {	
    	font-size: 50%;
    }
</style>
<div>
    Disables the accordion
</div>
<div style="height:250px">
    <div id="accordion">
        <h3>Tab 1 (I`m collapsible)</h3>
        <div>Tab 1 content</div>
        
        <h3>Tab 2 (I`m collapsible)</h3>	
        <div>Tab 2 content</div>
        
        <h3>Tab 3 (I`m collapsible)</h3>
        <div>Tab 3 content</div>
    </div>
</div>
<div style="margin-top:50px">
    <input type="radio" name="disable" id="disableaccordion" checked value="disable">Disable accordion
    <input type="radio" name="disable" id="enableaccordion" value="enable">Enable accordion
</div>

    
在线测试程序
© 2012 PureExample.com contact