Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know the reason of blur?

Tags:

How can I know which event caused a blur event in jQuery?

Blur event triggered using click or tab etc. How can I know this blur event is due to click or tab?

like image 681
ramesh.c Avatar asked Jun 20 '11 12:06

ramesh.c


1 Answers

If you are trying to do two different things depending on which method was used, bind handlers to listen for .click() and .keyup(), then check for the keycode

var k = (window.event) ? event.keyCode : e.keyCode; 

Or something on the order of this if you need

$(document).bind("click keyup", function(){    //check keycode    var e = (window.event);    var k = (e)?event.keyCode:e.keyCode;    if(k==9){       //tab code    }else if(e.type=='click'){       //click code    }  }); 
like image 65
Tank Avatar answered Sep 29 '22 14:09

Tank