samedi 1 décembre 2018

jQuery differentiate between click() and dblclick()

I'm making a simple tic tac toe game for two players using jQuery. I want to insert "X" when user clicks and "O" when double clicks. This is what I used

 $(document).ready(function(){
        $(".tic").click(function(){
            $(this).append("X");
        });
        $(".tic").dblclick(function(){
            $(this).append("O");
        });
    });

When a user double clicks a "X" and then "O" is displayed.




Aucun commentaire:

Enregistrer un commentaire