I am amateur and need a bit of help with my second reset button

Hi guys,

First of all thanks for reading this. I need a bit of help, my second reset button do not want to work.

here is a pen to check it out.

Thanks in advance for any advice

Hello @Mikra .

You seem to have passed the wrong id while referencing the element in the resetCat() function. The div you should reference has the id: flex-catgen and not generateCat

I tried it out and it’s working perfectly.

I think he needs to give the images he is creating an id and target it. I don’t think we want to remove the containing div.

But since it can create more than one image, and ids must be unique, you’d have to give it a class or you’d have to select the children of the containing div.

1 Like

HI @alekskimeu !

Thanks for your help!!! Seems it is time to stop for today :smiley:

Oh, yes. This would be the best solution. Remove the images instead of the whole div.

Hi @Mikra

@kevinSmith idea would be the best solution. Remove the images on reset instead of removing the whole div containing the images.

Hi @kevinSmith you are right! Thanks for the heads up!

Hello @kevinSmith

How about setting the innerHTML of the div to an empty string? @Mikra

I’m not sure, that might work. Or null or something. There might be some function that empties out a node. I don’t do much vanilla DOM manipulation. I just thought you should only remove what you added.

Hi @kevinSmith @alekskimeu .

I have set innerHtml to an empty string and it works.

1 Like

@alekskimeu However you have been 10 min faster then me :slight_smile: