You should handle the Event
focus
.
Demo -
[Demo] Detect TextBox Focus[
^]
$("#textbox").focus(function () {
alert("TextBox is Focused. The Div will Fade Out Now");
$('#div').fadeOut(2000);
});
Note the Changes here...
#textbox
-> # is appended to select the
TextBox
with
ID
.
$('#div').fadeOut(2000);
-> quotes around
#div
were missing.