<!DOCTYPE?html>
<html>
<head>
????<meta?charset="UTF-8">
????<title></title>
????<style?type="text/css">
????????li{
????????????width:?100px;
????????????height:?20px;
????????????line-height:??20px;
????????????position:?relative;
????????????margin:?10px;
????????}
????????button?{
????????????position:?absolute;
????????????right:?3px;
????????????top:?1px;
????????????height:?20px;
????????????/*?隱藏深處按鈕?*/
????????????display:none;
????????}
????????.123:hover?button?{
????????????/*?顯示刪除按鈕?*/
????????????display:inline;
????????}
????</style>
????<script?type="text/javascript">
????????//定義按鈕點(diǎn)擊事件del,刪除上級(jí)節(jié)點(diǎn)
????????function?del(){
?????????var?e=e||window.event;
?????????var?el=e.srcElement;
?????????var?li=el.parentNode;
?????????li.parentNode.removeChild(li);
????????}?
????</script>
</head>
<body>
<ul>
????<li?class="123">內(nèi)容1<button?onclick="del(this)">刪除</button></li>
????<li>內(nèi)容2<button?onclick="del(this)">刪除</button></li>
????<li>內(nèi)容3<button?onclick="del(this)">刪除</button></li>
????<li>內(nèi)容4<button?onclick="del(this)">刪除</button></li>
????<li>內(nèi)容5<button?onclick="del(this)">刪除</button></li>
</ul>
</body>
</html>
我加上了class標(biāo)簽,為啥不行了?
像個(gè)好人
2017-07-22 15:23:03