简体   繁体   English

JQuery中具有多个复选框级别的下拉列表

[英]drop down list with multiple check box levels in JQuery

I need to create a drop down list that contain multiple checkboxes as well as multiple levels. 我需要创建一个包含多个复选框以及多个级别的下拉列表。 The user should be able to select an option and/or dig deeper to select sub categorical. 用户应该能够选择一个选项和/或更深入地选择子类别。 See the example from the code below. 请参见下面的代码示例。

So far, I was able to create the drop down list and the check boxes. 到目前为止,我已经能够创建下拉列表和复选框。 I am having problems getting the id of the button selected and opening the corresponding div 我在选择按钮的ID并打开相应的div时遇到问题

http://jsfiddle.net/Ammarcola/e5CZb/ http://jsfiddle.net/Ammarcola/e5CZb/

How can I get the button working? 如何使按钮正常工作?

edit: I will explain my approach to make the code easier to read. 编辑:我将解释使代码更易于阅读的方法。 I am trying to create multiple with each of them containing a list of check boxes. 我试图创建多个,每个包含一个复选框列表。 Whenever a button is clicked, all the s should .hide() and only the requested would .show(). 每当单击按钮时,所有s都应为.hide(),只有被请求的将为.show()。 I am not worried about how the main would be reached again, but all the should reset once the drop down list is collapsed. 我不担心如何再次到达主菜单,但是一旦下拉列表折叠,所有的设置都应该重置。 Hope that helps. 希望能有所帮助。

I have given the corresponding id of the buttons to the Div's that have to be manipulated.. Then finding the button that was clicked and constructing the div that has to be opened.. Check this FIDDLE and let me know if this is what you were looking for .. Or is it a different requirement.. 我已经给必须操纵的Div分配了相应的按钮ID。然后找到被单击的按钮并构造必须打开的div。检查此FIDDLE ,让我知道这是否是您正在使用的寻找..还是其他要求。

$("button").click(function() {
    $("p").toggle();
     var btnID = $(this).attr('id');

    var coresDiv = $('div#' + btnID);

    coresDiv.toggle();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM