Jquery obligé de faire 2 clicks
Bonjour, j'ai chercher sur Google pour détecter click droit, gauche ou milieu et c'est pas compliqué.
Mon soucis et que je fais comme ça :
Le html
Code:
1 2
|
<span onclick="enchantAtk();" id="atkMinValue">10</span> |
Et coté JS :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
function enchantAtk()
{
$('#atk').mousedown(function(event) {
switch (event.which) {
case 1:
alert('Left mouse button is pressed');
break;
case 2:
alert('Middle mouse button is pressed');
break;
case 3:
alert('Right mouse button is pressed');
break;
default:
alert('Nothing');
}
});
} |
Le truc c'est que je dois clické 2 fois sur mon span pour qua l'alert s'affiche.
Quelqu'un aurais une solution pour ce petit problème ?
CDT