我想向其父 li 已单击的内容添加一些内容,并删除任何先前单击的 li 的 innerhtml?
<html>
<head>
<link rel="stylesheet" type="text/css" href="testtab.css"/>
<script type="text/javascript" src="scripts/jquery-1.10.1.min.js"></script>
<script>
$('#chat ul li a').on('click', function (e) {
alert("in");
alert($(this).closest('li').index());
});
</script>
</head>
<body>
<div id="chat" class="chat">
<ul class="chatmenu">
<li id="one" class="users"><a href="#one">abcy<span class="notify">1 new*</span></a>
<div class="chattng">
<ul class="overl">
</ul>
</div>
</li>
<li id="two" class="users"><a href="#two">avvv<span class="notify">a</span></a>
<div class="chattng">
<ul class="overl">
</ul>
</div>
</li>
<li id="three" class="users"><a href="#three">gtt<span class="notify">d</span></a>
</li>
<li id="four" class="users"><a href="#four">trt<span class="notify">e</span></a></li>
<li id="five" class="users"><a href="#five">kkk<span class="notify">f</span></a></li>
</ul>
</div>
</body>
</html>
一旦知道如何做到这一点,无论单击哪个 li,它的 innerhtml 都会得到一些东西,而单击的前一个 li 的 innerthtml 为空?