How to show last ID when All ID on DIV click

前端 未结 1 1909
心在旅途
心在旅途 2021-01-26 16:17

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 \"co

相关标签:
1条回答
  • 2021-01-26 16:52

    Please try this code.

     $(function () {
        var divs = ["wrong1", "wrong2", "wrong3", "wrong4"];
        $('#wrong1, #wrong2, #wrong3, #wrong4').click(function () {
            $(this).animate({
                opacity: 0,
               top: 100,
             }, 500);
        divs.splice(divs.indexOf($(this).prop("id")),1)
        if(divs.length == 0){
            $('#wrong-gameOne').eq(0).hide();
           $('#correct-gameOne').eq(0).show();
        }                
      });
    });
    

    Hope this will help you.

    Fiddle

    0 讨论(0)
提交回复
热议问题