出于某种奇怪的原因,我的网站复制了一个 div
元素。在我试图找到它被复制的原因之前,我正在研究一种暂时隐藏重复的 div
的方法。
我试过以下脚本:
$(document).ready(function() {
$('.ms-account-wrapper').eq(1).remove();
});
html:
<div class="ms-account-wrapper">1</div>
<div class="ms-account-wrapper">2</div> <---want to remove this one
有什么想法吗?
非常感谢
最大
最佳答案
选择并remove()
所有具有 .ms-account-wrapper
类的元素,第一个元素除外:
$(".ms-account-wrapper:not(:first)").remove();
无论有多少 .ms-account-wrapper
元素,这都有效
关于jquery - 使用 JQuery 删除重复的 div 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38897285/