In the following code how to remove the .e_data which is greater than s_arr.topics.length
For example if s_arr.topics.length = 2 and $(".e_data").length = 5 ..Then in this case want to remove the elements 3rd .e_data,4th .e_data,5 .e_data
how to do this
if($(".e_data").length > s_arr.topics.length)
{
$('.e_data').last().remove();
}
asked Aug 30, 2013 at 8:47
1 Answer 1
You can use slice():
$(".e_data").slice(s_arr_topics.length).remove();
answered Aug 30, 2013 at 8:49
Comments
lang-js
length
greater thans_arr.topics.length
?