In my case, I have select some elements base on $(‘a,form,[onclick]’), however, since there some elements are contain onclick attribute, it will be got twice. I want to remove the same element object from this element set. What I do is use codes below, however, it doesn’t work:
total = $('a,form,[onclick]')
$(total).each(function(index, element) {
for(var i=index;i<total.length;i++){
if($(this)[0] == $(total[i])[0]){
$(total[i]).remove();
}
}
});
How should I solve this problem, please help, thanks
Try to use unique function: