gpt4 book ai didi

javascript - 从 jstree 中获取选中的复选框

转载 作者:行者123 更新时间:2023-11-30 16:05:07 29 4
gpt4 key购买 nike

我有一个带有复选框的 jstree。当我选择一个节点并单击按钮时,我将获得该节点的名称。但现在我想允许多项选择,以便我将复选框分配给 jstree 每个元素。不,我怎样才能得到所选节点的 c=value。我也想允许搜索,但我不知道该怎么做。

我启用了 ssearch 插件。这是我的代码

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<style>
html { margin:0; padding:0; font-size:62.5%; }
body { max-width:300px; min-width:100px; padding:20px 10px; font-size:14px; font-size:1.4em; }
h1 { font-size:1.8em; }
.demo { overflow:auto; border:1px solid silver; min-height:100px; }
</style>
<link rel="stylesheet" href="style.min.css" />
</head>
<body>
<div id="frmt" class="demo"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="jstree.min.js"></script>
<button>>></button>

<script>
$('#html').jstree();
$('#frmt').jstree({
'core': {
'data':[{"id":"NODE 1","text":"node 1","children":[{"id","node 2","text":"node2"}]}]
},
"checkbox" : {
"whole_node" : false,
"keep_selected_style" : true,
"three_state" : true,
"tie_selection" : false
}, "search" : {
"fuzzy" : true
},"plugins" : [ "checkbox", "search", "state", "wholerow", "types", "selectopens" ]
});
$('#frmt').on("changed.jstree", function (e, data) {
console.log(data.selected);
});
$('button').on('click', function () {
alert($('#frmt').jstree("get_selected"));
});
</script>

</body>
</html>

最佳答案

你可以通过

alert($('#frmt').jstree("get_checked"));

关于javascript - 从 jstree 中获取选中的复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37154029/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com