Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - check if first click

I have 2 functions (A and B) called on a single div click. I need to call function A only on first click and function B whenever it is clicked. How could I do this?

like image 995
Lewis Avatar asked Mar 20 '14 16:03

Lewis


1 Answers

Much simpler solution:

$('element').one('click',function(){
// Call A
}).click(function(){
// Call B
});
like image 173
Amit Joki Avatar answered Sep 18 '22 20:09

Amit Joki