$('[id]').each(function () {
var ids = $('[id="' + this.id + '"]');
// remove duplicate IDs
if (ids.length > 1 && ids[0] == this) $('#' + this.id).remove();
});
The above will remove the first duplicate ID, however I want to remove the last. I've tried $('#'+ this.id + ':last')
but to no avail.
In the fiddle the input with the value 'sample' should be kept when the append action takes place.
$(this).attr('id') === this.id
– Circulate