js模拟删除父元素案例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript">
window.onload = function(){
var btnS = document.querySelectorAll('button');
btnS.forEach(function(item,idx){
item.onclick = function(){
//隐藏
item.parentNode.style.display = 'none';
// this.parentNode.style.display = 'none';
}
})
}
</script>
</head>
<body>
<ul>
<li>1231324242424 <button>删除</button> </li>
<li>1231324265465 <button>删除</button> </li>
<li>1231324765765 <button>删除</button> </li>
<li>1231324765765 <button>删除</button> </li>
<li>1231324765765 <button>删除</button> </li>
<li>1231324765765 <button>删除</button> </li>
</ul>
</body>
</html>
本文来自博客园,作者:JackieDYH,转载请注明原文链接:https://www.cnblogs.com/JackieDYH/p/17634790.html