我想使用JQuery从HTML中删除以下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,但我似乎无法成功地适应这种情况。
如果有人有任何见解并可以帮助我,我将不胜感激。
请注意,&#34; img data-src,data-image,alt和src会不时更改,因此我可能希望删除div类的所有实例。
答案 0 :(得分:2)
使用:
$(".main-image.content-fill").remove();
如果您只想从此DIV中删除内容,则可以使用EMPTY方法:
$(".main-image.content-fill").empty();