remove不能带参数吗,怎么删除不了,求指点
jquery吧
全部回复
仅看楼主
level 3
dsdyjg 楼主
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-2.1.1.min.js" ></script>
<style>
#test{background: red;;}
</style>
</head>
<body>
<div id="test">
<h1>jQuery end()方法</h1>
<p class="page_next">讲解jQuery中end()方法。</p>
</div>
<script>
$(document).ready(function() {
$("#test").click(function() {
$("#test").remove("p");
});
});
</script>
</body>
</html>
2016年03月07日 02点03分 1
level 3
dsdyjg 楼主
难道没有人知道吗?
2016年03月07日 02点03分 2
level 3
dsdyjg 楼主
高手在哪里呢?
2016年03月07日 02点03分 3
level 1
楼主对.remove()带参数的理解有一点偏差
.remove()带参数 是在jQuery对象集合本身中进行匹配移除
而不是对其子节点进行匹配
如果要对jQuery对象集合的子节点进行筛选删除 请用 .filter()方法
2017年12月18日 02点12分 5
level 1
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="../../js/jquery-3.2.1.min.js" ></script>
<style>
#test{background: red;}
</style>
</head>
<body>
<span class="test" id="no1">
<h1>jQuery end()方法</h1>
<p class="page_next">讲解jQuery中end()方法。</p>
</span>
<span class="test" id="no2">
<h1>jQuery end()方法</h1>
<p class="page_next">讲解jQuery中end()方法。</p>
</span>
<span class="test" id="no3">
<h1>jQuery end()方法</h1>
<p class="page_next">讲解jQuery中end()方法。</p>
</span>
<button id="test">移除方法</button>
<script>
$(document).ready(function() {
$("#test").click(function() {
$(".test").remove("#no3");
// $(".test").remove();
console.log('removing');
});
});
</script>
</body>
</html>
2017年12月18日 02点12分 6
level 1
如果感觉听着绕 我把你的代码改了下 你执行下应该就明白了
2017年12月18日 02点12分 7
1