Home > Web Front-end > JS Tutorial > js closes the menu outside the range drop-down menu when clicked

js closes the menu outside the range drop-down menu when clicked

小云云
Release: 2018-05-22 09:49:46
Original
1789 people have browsed it

This article mainly shares with you a js method to close the menu outside the range of the drop-down menu when clicked. It has a good reference value and I hope it will be helpful to everyone. Let’s follow the editor to take a look, I hope it can help everyone.

The example is as follows:

$(function(){
  $(document).bind("click",function(e){
    //id为menu的是菜单 
    if($(e.target).closest("#menu").length == 0 && $(e.target).closest("input").length == 0){
    //点击id为menu之外且id,则触发
    hideMenu();
    }
  })
})
Copy after login

Related recommendations:

ajax drop-down menu Cascade operation

jQuery implementation of drop-down menu method sharing

jQuery implementation of drop-down menu accordion effect sharing

The above is the detailed content of js closes the menu outside the range drop-down menu when clicked. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template