user4130410
user4130410

Reputation:

how to check that click event done by mouse Scroll click while form submit?

In my simple form, js_submit_loading is assigned to <form> and btn-loading is assigned to SEND <button>

Here is my js code:

    $('.js_submit_loading').on('submit',function (){
        $(this).find('#btn-loading').button('loading');
    });

Now, how can i detect that button was clicked by left mouse button or scroll button i only know that which==2 stands for scroll click.

thanks in adv. for help

Upvotes: 1

Views: 101

Answers (1)

V&#237;tor Martins
V&#237;tor Martins

Reputation: 1440

event.which will give 1, 2 or 3 for left, middle and right mouse buttons respectively.

$( "#whichkey" ).on( "submit", function( event ) {
  $( "#log" ).html( event.type + ": " +  event.which );
});

or

$('#submit').mousedown(function(event) {
    switch (event.which) {
        case 1:
            alert('Left Mouse button pressed.');
            break;
        case 2:
            alert('Middle Mouse button pressed.');
            break;
        case 3:
            alert('Right Mouse button pressed.');
            break;
        default:
            alert('You have a strange Mouse!');
    }
});

Upvotes: 1

Related Questions