weixin_33693070 2014-06-25 16:09 采纳率: 0%
浏览 122

手风琴中的复选框

I am trying to create a system using asp.net and I'd like to use an accordion.

I'd like my accordion to have a header with a check box and then once that check box is checked it will display check boxes in the content section, so it will look like this:

-HEADER

 -CONTENT

 -CONTENT

 -CONTENT

-HEADER

 -CONTENT

 -CONTENT

 -CONTENT

However, the headers that are displayed will depend on the selection from another check box and the two 'Headers' that are in the example will be in the same accordion. Is it possible to do this? I would need the ability to select multiple check boxes as well, so I'm not sure whether using a checkbox or a checkboxlist would be the best way to go

Sorry if I haven't made myself very clear Please, tell me if you need some more info

Many thanks

  • 写回答

1条回答 默认 最新

  • weixin_33728708 2018-08-29 13:15
    关注

    Please try this html code

    <link href = "https://code.jquery.com/ui/1.12.0/themes/smoothness/jquery-ui.css" rel = "stylesheet" />
    <script src = "https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
    <div id="accordion">
        <h3>
            <label for='product-44-44'>
                <input type='checkbox'  name="header" value="header" id="header"/>
                HEADER
            </label>
        </h3>
        <div class="columns">
            <div class="d1">
                <label>
                    <input type="checkbox" name="content1" value="content1" id="content1">
                    CONTENT 1
                </label>
            </div>
            <div class="d1">
                <label>
                    <input type="checkbox" name="content2" value="content2" id="content2">
                    CONTENT 2
                </label>
            </div>
        </div>
    </div>
    $("#accordion")
                .accordion({
                    collapsible: true,
                    active: false,
                    heightStyle: "content",
                    beforeActivate: function (event, ui) {
                        var oldInput = ui.oldHeader.find('input');
                        oldInput.prop('checked', !oldInput.prop('checked')) // this bit unchecks when the accordion is closed
    
                        var newInput = ui.newHeader.find('input'); // this bit checks when the accordion is opened
                        newInput.prop('checked', !newInput.prop('checked'))
                    }
                });
    

    try to run code using to click this link https://jsfiddle.net/sunnykalariya/5v9aqjkf/

    评论

报告相同问题?

悬赏问题

  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真