mardi 12 juillet 2016

delaying a function to execute jquery


I want a button pressed, then the button changes style, and a new function loads, after about 1/2 second of the styling.

$(document).on('click', '.capital_answers', function(){
    if(!$('#capital_answers').hasClass('answered')) {
        answer = $(this).attr('data-answer');
        if(answer==1) {
            $(this).addClass('capital_correct');
            $('#capital_answers').addClass('answered');
            capital_correct()
        }
        else {
            $(this).addClass('capital_wrong');
            $('#capital_answers').addClass('answered');
        }
    delay(500).capital_next();  
    }
});

So as you can see I am using the delay() method currently, which helps in no way. What options are there in delaying a function in this manner?


Aucun commentaire:

Enregistrer un commentaire