<div id="@("Bottomgrid)" class="dgd2"></div>
var element = document.getElementById("#Bottomgrid");
element.empty();
$('.dgd2').empty()
它不仅删除底部网格,还删除屏幕中存在的其他 Div。
最佳答案
jQuery .remove()将从 DOM 中删除匹配的元素集。
而 jQuery .empty()将从 DOM 中删除匹配元素集的所有子节点。
考虑您的 HTML 是否如下所示:
<div id="Bottomgrid" class="dgd2"></div>
并且您想使用id="Bottomgrid"删除div
那么你的 JavaScript 代码将是:
$("#Bottomgrid").remove();
//This is not required as far as I see
//$('.dgd2').empty()
关于javascript - 仅删除特定 Div Id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38306074/