Jquery, how: click anywhere outside of the div, the div fades out -


How do I create it in Jquery if I have a div, inside it in different elements, a selection, a search input , Etc., when I click outside the div, on the page, div fade, but I can click on selection and type in the search input and it can not be faded? Any help is appreciated. The code duck response is incomplete because you should not

If you click on DIV itself (only outside), then fade out then say that your DIV which should be faded, has an ID of "menu".

  jQuery ("# ​​menu"). Click (function () {return false;}); JQuery (document) .one ("click", function () {jQuery ("# ​​menu"). FadeOut ();}); The use of  

one is more concise than tied / unbound. Apart from this, names of events are not really necessary here if you use a , because there is no need to explicitly attach a particular click handler to the document is not.

return false is simply saying "stop the document from bubbling this incident."


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -