Wednesday, 15 September 2010

javascript - Blur event not works for div -



javascript - Blur event not works for div -

here code below i'm trying hide addstuff id div when clicked out of it. tried body click event useless. need trigger event blur. doesn't work both blur , focusout events.

$(document).ready(function() { $('#addstuff').blur(function () { $('#addstuff').fadeout() }) })

there no blur event div. can create effect using click event of body.note should exclude div click event

$(document).ready(function () { $("body").not("#addstuff").click(function (e) { $("#addstuff").fadeout(); }); });

fiddle

edit

as @trueblueaussie suggested, improve utilize document instead of 'body' click event handler:

$(document).not("#addstuff").click(function (e) { $("#addstuff").fadeout(); });

javascript jquery html css

No comments:

Post a Comment