vendredi 22 avril 2016

else Statement not triggering

I think i'm missing something simple here but can't see it for the life of me. The 'if' part is working perfectly, but the 'else' isn't even being triggered (console log won't show).

The code itself is for a simple drag and drop, where #answer2 is the answer for #targetbox1.

Any ideas? Total JS noob here.

Thank you

$('.draggable').draggable({stack: "#page-lev2", revert: "invalid"});

$('#targetbox1').droppable({
    drop: function( event, ui ) {
        if(ui.draggable.is("#answer2")){
            $(this).css("background", "url('img/lev2/targetAreaCorrect.svg') no-repeat");
            $("#answer2").css("border", "none");
            addToCorrect();
        }
        else{
            console.log("why wont you work")
            wrong();
        }   
    }
});

function wrong() {
    $("#lev2-intro").addClass("hide");
    $("#lev2-wrong").removeClass("hide");
}

Aucun commentaire:

Enregistrer un commentaire