Iterate through multiple items and remove the first child of every item using jQuery
10:25 12 Feb 2018

I know it might be a little bit dumb, but I am really struggling with simple things like the following problem. Here is an example of the code that I have. The problem will be explained after the code. So here it is:

What I would like to do, is to keep every first item (image_item) of every div with the class "image" and remove the rest. How can I achieve that?

So far I got this, but it removes everything accept the first one on the first div.

$('.first_only .immo_image').not(':first').remove();

I also tried to iterate through each element with the following code:

$('. image').each(function () {
   $('.image_item').not(':first').remove();
});

But it does the same as with the other example. It removes everything, except the first image on the first div.

javascript jquery html css