JQuery JSTree - add a ToolTip

后端 未结 7 1295
小鲜肉
小鲜肉 2021-01-04 20:14

Is there a way to add a Tooltip to a JSTree node? I would like to display extra information when the user hovers over an element.

I\'m pretty dense when it comes to

7条回答
  •  隐瞒了意图╮
    2021-01-04 20:53

    Use the "a_attr" or "li_attr" to add a title, depending on which element you want the title to be on, as documented here: https://www.jstree.com/docs/json/

    If using the "create_node" function, then do it like this:

    $("#my_tree").jstree("create_node",
        "my_node",
        "inside", {
            "attr": {
                "id": "my_node"
            },
            "li_attr": { //or a_attr if you prefer
                "title": "my tooltip text",
                "class": "show_tooltip"
            },
            "text": "my node text"
        });
    

    The above will show a tooltip in the browser. If you want to use a custom tooltip (e.g. Bootstrap), then you can simply call $(".show_tooltip").tooltip();

提交回复
热议问题