Jquery not selector implementation element display hidden

Source: Internet
Author: User

At the beginning of the first acquaintance with jquery's not selector, the function you want to implement is to click on the first Div, display the second Div, click outside the first div to hide the second div.

The specific code is as follows:

<!DOCTYPE HTML><HTML><Head><Scriptsrc= "Http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></Script><Script>$ (document). Ready (function(){  $("#btn"). Click (function(){   $("#holder"). Toggle ();  }); $(": Not (#btn)"). MouseUp (function(){    $("#holder"). Hide (); });});</Script></Head><Body><H1>Welcome to My homepage</H1><DivID= "BTN"style= "Cursor:pointer;">I'm the button.</Div><DivID= "Holder"style= "Background-color:lightblue;"><P>I live in Duckburg.</P><P>My best friend is Mickey.</P></Div></Body></HTML>

It is important to note that both cannot trigger the Click event at the same time; Div1 called the Toggle () method cannot be hidden, only call show ().

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.