写一个程序:用jquery判断某个元素是否存在,若存在则删除该元素

可以使用 jQuery 的 length 属性来判断某个元素是否存在,如果存在的话,可以使用 jQuery 的 remove() 函数来删除该元素:$(document).ready(function(){ if ($('selector').length > 0) { $('selector').remove(); } });

猜你喜欢

转载自blog.csdn.net/weixin_35755434/article/details/129524630