I have this JStree which has links to files, I just want to open in in new tab. But even after having target as _blank does not open it in new tab.
<div id="jstree" class="jstree jstree-1 jstree-default" role="tree" aria-multiselectable="true" tabindex="0"
aria-activedescendant="j1_11" aria-busy="false">
<ul class="jstree-container-ul jstree-children" role="group">
<li role="treeitem" aria-selected="false" aria-level="1" aria-labelledby="j1_3_anchor" aria-expanded="true"
id="j1_3" class="jstree-node jstree-open"><i class="jstree-icon jstree-ocl" role="presentation"></i><a
class="jstree-anchor" href="#" tabindex="-1" id="j1_3_anchor"><i class="jstree-icon jstree-themeicon"
role="presentation"></i>
Files
</a>
<ul role="group" class="jstree-children">
<li role="treeitem" aria-selected="false" aria-level="2" aria-labelledby="j1_4_anchor" id="j1_4"
class="jstree-node jstree-leaf"><i class="jstree-icon jstree-ocl" role="presentation"></i><a
class="jstree-anchor glyphicon glyphicon-download-alt anchorTag" href="/file1" tabindex="-1"
target="_blank" id="j1_4_anchor"><i class="jstree-icon jstree-themeicon"
role="presentation"></i>
Slide 7.png
</a></li>
<li role="treeitem" aria-selected="false" aria-level="2" aria-labelledby="j1_5_anchor" id="j1_5"
class="jstree-node jstree-leaf"><i class="jstree-icon jstree-ocl" role="presentation"></i><a
class="jstree-anchor glyphicon glyphicon-download-alt anchorTag" href="/file2" tabindex="-1"
target="_blank" id="j1_5_anchor"><i class="jstree-icon jstree-themeicon"
role="presentation"></i>
Slide 6.jpg
</a></li>
</ul>
</li>
</ul>
</div>
you can use a class on click to get the href and target to open it
$("#jstree").jstree().on("click","anchorTag" function (e, data) {
var href = this.href;
window.open(href, this.attr.target)
});
there are many other ways also but this i find simple
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.