zoukankan      html  css  js  c++  java
  • jstree onselect回调方法,获取选中节点的值 Fred


    应用jstree的onselect事件,获取当前选中的节点的名字,并且赋值给一个input:
    <script type="text/javascript">
    function log(str) {
        $(
    "#log").prepend(str + "<br />");
    }
    $(
    function () {
        $(
    "#demo").tree({
          data  : {
            type  : 
    "json",
            json  : [ 
              { attributes: { id : 
    "pjson4_1" }, data: "Root node 1", children : [
                { attributes: { id : 
    "pjson4_2" }, data: { title : "Custom icon", icon : "../media/images/ok.png" } },
                { attributes: { id : 
    "pjson4_3" }, data: "Child node 2" },
                { attributes: { id : 
    "pjson4_4" }, data: "Some other child node" }
              ]}, 
              { attributes: { id : 
    "pjson4_5" }, data: "Root node 2" } 
            ]
          },
          rules : {
            droppable : [ 
    "tree-drop" ],
            multiple : 
    true,
            deletable : 
    "all",
            draggable : 
    "all"
          },
          callback : {
                    
    onselect    : function (NODE) {    $("#txtSelectedValue").val($(NODE).children("a").text())} 

          }
        });
    });
    </script>
  • 相关阅读:
    CSS+JS实现兼容性很好的无限级下拉菜单
    自动切换的JS菜单
    (2)C#连sqlite
    protobuf编译器
    (67) c# 序列化
    (66) c# async await
    (65)C# 任务
    mbatis 入门
    (64)C# 预处理器指令
    (63)C# 不安全代码unsafe
  • 原文地址:https://www.cnblogs.com/Fred_Xu/p/jstree_onselect_callback.html
Copyright © 2011-2022 走看看