How to show last ID when All ID on DIV click?

Hello everyone,

I am newbie with javascript.
i want to make mini game quiz. But stuck on this logic.

Try see my code below,
I want to replace div ID “wrong-gameOne” with div ID “correct-gameOne”
after click all div ID wrong1, wrong2, wrong3, wrong4,

I have try make it, but after click one ID “wrong 1” or other, div ID “correct-gameOne” is show. I don’t want like this.
Please give me fix my script below how to make it.
Sorry for my bad english.
Thanks so much :blush:

Script :

 $(function () {
    $('#wrong1, #wrong2, #wrong3, #wrong4').click(function () {
        $(this).animate({
            opacity: 0,
            top: 100,
        }, 500);
        
        var divs = ['#wrong1, #wrong2, #wrong3, #wrong4'];

        if ($(this).next(divs).length === 1)
            $('#wrong-gameOne').eq(0).hide();
        else
            $('#correctOne').eq(0).show(); 
});

I would add some special class to each clicked block and then count how many blocks already have that class
Demo implementation: https://jsfiddle.net/9o08v2fe/

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.