2015-12-01 44 views
-2

我想使用JQuery从HTML中删除下面的div。使用JQuery去除div类

<div class="main-image content-fill" style="overflow: hidden;"> 
<img data-src="http://static1.squarespace.com/static/53a8e280e4b0222e1cd90549/53bb1263e4b053aeb1247ba7/5657e934e4b08c62b9d0afa6/1448853091831/" data-image="http://static1.squarespace.com/static/53a8e280e4b0222e1cd90549/53bb1263e4b053aeb1247ba7/5657e934e4b08c62b9d0afa6/1448853091831/" data-image-dimensions="600x338" data-image-focal-point="0.5,0.5" alt="How To Pick a Pumpkin and the History of Halloween " class="" src="http://static1.squarespace.com/static/53a8e280e4b0222e1cd90549/53bb1263e4b053aeb1247ba7/5657e934e4b08c62b9d0afa6/1448853091831/?format=2500w" data-image-resolution="2500w" style="top: -61px; left: 0px; width: 792px; height: 447px; position: relative;"> 
</div> 

我觉得这是非常相似,我已经提出here另一个问题,但我似乎不能成功地使其适应这种情况。

如果有人有任何见解,并可以帮助我,我将不胜感激。

注意“IMG数据-SRC,数据图像,ALT和src改变不时这样可能我想删除的DIV类的所有实例

+0

要删除文档中的元素,['一个.remove()'](HTTP:// api.jquery.com/remove/)。 –

回答

2

使用此:

$(".main-image.content-fill").remove(); 

如果你只是想去掉从这个DIV的内容,你可以使用空方法:

$(".main-image.content-fill").empty();