[英]how to remove a div on the basis of a class using jQuery
I'm using this to remove the div whenever I call my showresult();
每当我调用showresult();
时,我都会使用它来删除div showresult();
function. 功能。 I am dynamically creating this div <div class="sampageswrapper">
, so this needs to be removed when ever showresult()
is called. 我正在动态创建此div <div class="sampageswrapper">
,因此在调用showresult()
时需要将其删除。
function showresult(data) {
jQuery('.sampageswrapper div').remove();
// rest of my code.
}
But unfortunately this div is not removing. 但是很遗憾,这个div并没有移除。
<div class="sampageswrapper">
<div id="image_div" class="img_class" name="image_div">
..........
</div>
</div>
you can use the .samepageswrapper
selector only 您只能使用.samepageswrapper
选择器
jQuery('.sampageswrapper').remove();
it should target that specific div. 它应针对该特定的div。
when you use .sampageswrapper div
as your selector, this targets all the div's inside the div element with sampageswrapper
class 当您使用.sampageswrapper div
作为选择器时,这将使用sampageswrapper
类将div元素中的所有div定位为目标
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.