点击LI没有反应

提问 未结
16 293
syjphp
syjphp 2018-11-16
悬赏:30飞吻
版本:layui 2.4.5 浏览器:QQ
.layui-nav-tree这个类下面动态添加了LI,LI里再添加DL,DL添加DD,为什么点击的时候却不会展开DL

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SupplyPlatform.Default" %>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>供应商平台主界面</title>
<link href="JS/css/layui.css" rel="stylesheet" />
<link href="JS/css/fs.css" rel="stylesheet" />
<link href="JS/dist/css/layui.css" rel="stylesheet" />
<script src="JS/jquery-3.3.1.min.js"></script>
<script src="JS/layui.js"></script>


<script type="text/javascript">
var MoudleNameList = "";
$(function () {
var targetMainID = "",targetChildID="";
var htmlli = "";
//var $newNode = $("<li class='layui-nav-item'><a href=''>控制台223</a></li>");
//$(".layui-nav-tree").append($newNode);
$(".layui-nav-child dd a").click(function () {
$("iframe").attr("src", "/SupplyOrder.aspx");
});
$(document).click(function (e) { // 在页面任意位置点击而触发此事件
targetID = $(e.target).attr("id"); // e.target表示被点击的目标
})
$.ajax({
type: "get",
url: "http://192.168.8.46:6060/FJSupplyFlatForm/GetSupplyMoudle",
async: true,
data: "",
contentType: "application/json",
success: function (result) {
MoudleNameList = JSON.parse(JSON.stringify(result));

for (var i = 0; i < MoudleNameList.length; i++)
{
var targetMainID = MoudleNameList[i].ID;
htmlli = "<li class='layui-nav-item' ><a href='javascript:;' >" + MoudleNameList[i].FMoudleName + "</a>";
var MoudleDetail = MoudleNameList[i].SupplyMoudleEntry;
htmlli += "<dl class='layui-nav-child'>";
for (var j = 0; j < MoudleDetail.length; j++) {

htmlli += "<dd><a href='javascript:;'>" + MoudleDetail[j].FMoudleName+ "</a></dd>";
}
htmlli += "</dl></li>";
$(".layui-nav-tree").append(htmlli);
}

},
error: function (result) {
layer.msg('接口调用异常', { icon: 2, time: 2000 });
}
});
});

layui.use('element', function () {
var element = layui.element;

});
</script>
</head>
<body class="layui-layout-body">

<div class="layui-layout layui-layout-admin">
<div class="layui-header">
<div class="layui-logo"></div>
<!-- 头部区域(可配合layui已有的水平导航) -->
<ul class="layui-nav layui-layout-left">
<li class="layui-nav-item" ><a href="">控制台</a></li>
<li class="layui-nav-item"><a href="" >商品管理</a></li>
<li class="layui-nav-item"><a href="">用户</a></li>
<li class="layui-nav-item">
<a href="javascript:;">其它系统</a>
<dl class="layui-nav-child">

<dd><a href="">邮件管理</a></dd>
<dd><a href="">消息管理</a></dd>
<dd><a href="">授权管理</a></dd>
</dl>
</li>
</ul>
<ul class="layui-nav layui-layout-right">
<li class="layui-nav-item">
<a href="javascript:;">
<img src="http://t.cn/RCzsdCq" class="layui-nav-img">
贤心
</a>
<dl class="layui-nav-child">
<dd><a href="">基本资料</a></dd>
<dd><a href="">安全设置</a></dd>
</dl>
</li>
<li class="layui-nav-item"><a href="">退了</a></li>
</ul>
</div>

<div class="layui-side layui-bg-black">
<div class="layui-side-scroll">
<!-- 左侧导航区域(可配合layui已有的垂直导航)<li class="layui-nav-item layui-nav-itemed"> -->
<ul class="layui-nav layui-nav-tree" lay-filter="test">
<li class="layui-nav-item layui-nav-itemed">
<a href="javascript:;">所有商品</a>
<dl class="layui-nav-child">
<dd><a href="javascript:;">列表一</a></dd>
<dd><a href="javascript:;">列表二</a></dd>
<dd><a href="javascript:;">列表三</a></dd>
<dd><a href="javascript:;">腾讯2</a></dd>
</dl>
</li>

</ul>
</div>
</div>
<!-- 右边内容区域 -->
<div class="layui-body layui-form">
<div class="layui-tab layui-tab-card fsTab" lay-filter="fsTab" lay-allowClose="true">

<!-- 菜单导航 -->
<ul class="layui-tab-title" id="fsTabMenu">
<li class="layui-this" lay-id="111"><i class="layui-icon"></i><cite>首页</cite><p class="layui-tab-close" style="display: none;"></p></li>
</ul>

<!-- 内容 -->
<div class="layui-tab-content">
<div class="layui-tab-item layui-show" lay-id="1">
<iframe ></iframe>
</div>
</div>
</div>
</div>

<div class="layui-footer">
<!-- 底部固定区域 -->
© layui.com - 底部固定区域
</div>
</div>
</body>
</html>
回帖