简体   繁体   English

捕获标签点击事件

[英]Capture label click event

i am using jqxWidgets The tree menu and cannot seem to find a way to capture the click event of a label in jquery. 我正在使用jqxWidgets树菜单,似乎无法找到一种方法来捕获jquery中标签的click事件。 Is there a way to capture this label in jquery for processing? 有没有办法在jquery中捕获此标签进行处理? I have included the relevant snippet of code and would appreciate your expert advice. 我已经提供了相关的代码片段,非常感谢您的专家建议。 Many thanks 非常感谢

 <script type="text/javascript">
  $(document).ready(function () {
    var source = [
    { label: "Weekly Reports", expanded: false, items: [
        { label: "Intake" },
        { label: "Retrieval", selected: false },
        { label: "Returns", selected: false }
    ]
    },
    /*{ label: "Item 2" },
    { label: "Item 3" },*/
    { label: "Monthly Reports", items: [
        { label: "Item 4.1" },
        { label: "Item 4.2" }
    ]
    },
    /*{ label: "Item 5" },
    { label: "Item 6" },
    { label: "Item 7" }*/
    { label: "Movement Reports", items: [
        { label: "Item 4.1" },
        { label: "Item 4.2" }
    ]
    },
     { label: "Destruction Reports", items: [
        { label: "Item 4.1" },
        { label: "Item 4.2" }
    ]
    },
];
  var theme = "";
  // Create jqxTree
  $("#jqxTree").jqxTree({ source:source, theme: theme });

  // Create jqxExpander
  $("#jqxExpander").jqxExpander({  showArrow: false, toggleMode: "none", width: "262px", height: "auto", theme: theme });
  });
</script>

The jqxTree has a built in callback for the select event. jqxTree具有一个用于select事件的内置回调。 You can capture this event and retrieve the label that was clicked like so: 您可以捕获此事件并检索被单击的标签,如下所示:

$('#jqxTree').on('select',function (event){
    var args = event.args;
    var item = $('#jqxTree').jqxTree('getItem', args.element);
    var label = item.label; 
});

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

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