Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
100
rated 0 times [  106] [ 6]  / answers: 1 / hits: 75353  / 13 Years ago, thu, march 17, 2011, 12:00:00

I have a JavaScript that displays a DIV (sets its display css property from 'none' to 'normal'. Is there a way to give it focus as well so that when I click somewhere else on the page, the DIV loses focus and its display property is set to none (basically hiding it). I'm using JavaScript and jQuery


More From » jquery

 Answers
9

For the hide the div when clicking any where on page except the selecteddiv



$(document).not(#selecteddiv).click(function() {
$('#selecteddiv').hide();
});


if you want to hide the div with lost focus or blur with animation then also



$(#selecteddiv).focusout(function() {
$('#selecteddiv').hide();
});


with animation



$(#selecteddiv).focusout(function() {
$('#selecteddiv').animate({
display:none
});
});


May this will help you


[#93226] Wednesday, March 16, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
matteo

Total Points: 81
Total Questions: 100
Total Answers: 96

Location: Honduras
Member since Sat, Jul 24, 2021
3 Years ago
;