问题描述
我有一个树形图,应该有物品和子物品。
这应该是我的模式,
| 111
||| 222
| 444
||| 333
| 555
||| 666
。
。
。
.etc
因此,基于上面的例子,所以当我点击'111'时,它应该在'111'下产生'222'作为子项只有一次,这适用于'444'和'555'。我的要求是'111'是一个文件夹,'222'是子文件夹。所以当我点击一个文件夹时,它应该生成该文件夹中的子文件夹。请帮忙怎么做
我尝试过:
HTML
Hi,
I have a treeview that should have items and sub items.
This should be my pattern like,
|111
|||222
|444
|||333
|555
|||666
.
.
.
.etc
So based on my above example, So when I click on '111', it should generate '222' under '111' as a sub item only once, which is applicable for '444' and '555'. My requirement is '111' is a folder and '222' is subfolder. So when I click on a folder, then it should generate the subfolders inside that folder. Please help how to do this
What I have tried:
HTML
<li id='click'>".$folderList[$ind]."</li>
Javascript
Javascript
<script>
var handleAdd = function (event) {
var $this = $(this);
if ($this.children('ul').length > 0) {
$('<li></li>').appendTo($this.children('ul'));
} else {
$('<ul><li></li></ul>').appendTo($this);
}
event.stopPropagation();
};
$(document).on('click', 'li', handleAdd);
</script>
推荐答案
Javascript
Javascript
<script>
var handleAdd = function (event) {
var
这篇关于如何在每个项目上添加子项在HTML树视图中动态单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!