remove last append element jquery

Basharat Ali picture Basharat Ali · Oct 30, 2009 · Viewed 86.9k times · Source

I have the following code:

$(this).children("a:eq(0)").append('<img src="'+ (arrowsvar.down[1]) 
    +'" class="' + (arrowsvar.down[0])
    + '" style="border:0;" />'
);

Now I want to remove last appended element (an image). Please give suggestions.

Answer

Arthur Kushman picture Arthur Kushman · Mar 15, 2013

As an alternative, for those who likes more programmatic ways and syntax:

$('#container-element img').last().remove();