在$.ajax({})中,append()拼接jsp语句后子菜单无法展开

<!DOCTYPE html>

<html>

<head>

<title>SaaS</title>

<link href="style/bootstrap.css" rel="stylesheet">

<link rel="stylesheet" href="style/font-awesome.css">

<link href="style/style.css" rel="stylesheet">

<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>  

</head>

<body>

<div class="content">

    <div id="menu" class="sidebar">

        <div class="sidebar-dropdown"></div>

    </div>

</div>

<script>   

    $.ajax({

        url:'GetmenuServlet',

        type:'get',

        dataType:'text',

        success:function (data) {

            var html ="<ul id='nav'>";

                html+="<li><a href='index.jsp' class='open'><i class='icon-home'></i> 首页</a></li>";

                    html+="<c:if test='${username!=null}'>";

                   html+="<li class='has_sub'><a href='#'><i class='icon-home'></i>应用测试";

                html+="<span class='pull-right'><i class='icon-chevron-right'></i></span>";

                html+="</a>";

                html+="<ul>";

                html+="<li><a href='index.jsp'>租户管理</a></li>";

                html+="<li><a href='index.jsp'>租户管理2</a></li>";

                html+="</ul>";

                html+="</li>";

                html+="</c:if>";

                html+="</ul>";

            $('#menu').append(html);

        }

    });

</script> 

<script src="js/jquery.js"></script>

<script src="js/bootstrap.js"></script>

<script src="js/custom.js"></script>

</body>

</html>

其中应用测试菜单下的两个子菜单无法展开,个人觉得是custom.js里的动作没有实现,但是怎么也改不出来,求如何实现


慕运维8079593
浏览 694回答 1
1回答

BIG阳

&nbsp; &nbsp; &nbsp; &nbsp; var html ="<ul id='nav'>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="<li><a href='index.jsp' class='open'><i class='icon-home'></i> 首页</a></li>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="<c:if test='${username!=null}'>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="<li class='has_sub'><a href='#'><i class='icon-home'></i>应用测试";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="<span class='pull-right'><i class='icon-chevron-right'></i></span>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="</a>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="<ul>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="<li><a href='index.jsp'>大大管理</a></li>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="<li><a href='index.jsp'>租户dddd管理2</a></li>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="</ul>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="</li>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="</c:if>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="</ul>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; html+="<script src='js/custom.js'><\/script>";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#menu').append(html);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 要把<script src='js/custom.js'><\/script>页拼接在html中才会有效
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript