gpt4 book ai didi

javascript - JSTree 列表和 anchor

转载 作者:行者123 更新时间:2023-12-03 08:06:12 26 4
gpt4 key购买 nike

嘿,大家好,我需要一些帮助,我有一个 JSTREE,其中有一些可以重定向到我的 html 网页的一部分我正在尝试找出 jstree 函数,现在可以提供帮助,我有这个: http://pastebin.com/ZTSYXWpt

这是法语的 html 代码:http://pastebin.com/TpLhWASp现在发生的情况是,如果我单击一个名为第 1 节、第 2 节、第 3 节或 wtv 编号的节点,它会将我重定向到该节点本身,而不是 href 链接,而不是 li 中的链接。有什么帮助吗?

(我可以在没有 jstree 的情况下执行此操作,单击带有 anchor 的链接并将页面上的用户重定向到该部分,但我无法使用 jstree 执行此操作)

这个功能是当你点击它时它会将你重定向到 html 页面中的指定部分

$(document).ready(function() {
$('div').eq(0).jstree();
$("#catTree li").on("click", "a", function() {

document.location.href = this;
});

});

这是在 html 中创建我的列表的 html 代码的一部分

    <body>
<h1>Categorie</h1>
<div id="catTree">
<ul class="n1">
<span>Liste Categorie</span>
<li>
Categorie
<ul class="n2">
<li>
<a class="menu" href="#section1">Section 1</a>
</li>
<li>
<a class="menu" href="#section2">Section 2</a>
</li>

这就是当您单击 JStree 节点时它应该指向您的位置

            <header>

<p>
Nom fabricant
<p>
<a name="section1"> Section 1</a>
</header>
<br>
<figure>
<p>
description1
</p>
<figcaption>
blabla
</figcaption>
<img src="images/hat1.jpg" alt="hat"/>
</figure>
<br>
<footer>
<p>
Prix : 00$$
</p>
<a href= "#section12"> Dernière section</a>
</footer>

如果您想了解更多信息,请进入 html Pastebin 文件,查看更清晰的代码,但如果您查看它,有 12 个部分完全相同,我希望这些 jstree 节点重定向到这些部分

最佳答案

这似乎是 How to get I get leaf nodes in jstree to open their hyperlink 的重复

检查http://codepen.io/anon/pen/gPryPR

$('div#catTree').jstree().bind("select_node.jstree", function (e, data) {
var href = data.node.a_attr.href;
document.location.href = href;
});

关于javascript - JSTree 列表和 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34374936/

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