删除最后一个append元素jquery

前端之家收集整理的这篇文章主要介绍了删除最后一个append元素jquery前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有以下代码
$(this).children("a:eq(0)").append('<img src="'+ (arrowsvar.down[1]) 
    +'" class="' + (arrowsvar.down[0])
    + '" style="border:0;" />'
);

现在我想删除最后附加的元素(图像)。请给出建议。

解决方法

你可以使用 :last-child选择器找到最后一个附加的元素,那么你可以 remove它:
$('img:last-child',this).remove();
// get the last img element of the childs of 'this'
原文链接:https://www.f2er.com/jquery/183723.html

猜你在找的jQuery相关文章