Basically I am trying to implement a login such as that of the new twitter. When you click on Sign In a div pops up with the fields. Now when I click anywhere outside the div (div losing focus) then the div should disappear.
I have tried the technique mentioned at How to blur the div element?
The code is as follows
$("body").click(function(evt) {
if (evt.target.id !== 'loginDialog') {
$("#loginDialog").hide();
}
});
The trouble with that is the target.id will not equal to loginDialog even if I click somewhere withing loginDialog say within a child div.
So the above is a good direction to proceed towards, but the solution is incomplete.
What is the best way to achieve this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…