$(".rows .cell").click(function(e) { e.preventDefault(); if($(this).parent().hasClass("row-"+ result_2)) { var random = Math.floor(Math.random()*10); app.pickMiner(id); mine_button = $(this); } console.log("CELL CLICK"); }) Everything works, it changes, but sometimes it changes only when the element is clicked twice. Not so twice as with double click, but just the first time it does not work. Clicked - nothing happens. To open the item, you need to click again.