Jquery Implementation of hovering the mouse to display the second-level menu effect, floating jquery

Source: Internet
Author: User

Jquery Implementation of hovering the mouse to display the second-level menu effect, floating jquery

1. Layout:

<Div class = "show">  <div class =" drop "style =" display: none; z-index: 80000 "id =" profileMenu "> <ul> <li> <a class =" pass "style =" cursor: pointer "href = '#'> <span> Change Password </span> </a> </li> <a class =" quit "style =" cursor: pointer "href = '#'> <span> exit </span> </a> </li> </ul> </div>

2. js control:

function dropMenu(obj) { $(obj).each(function () { var theSpan = $(this); var theMenu = theSpan.find(".drop"); var tarHeight = theMenu.height(); theMenu.css({ height: 0, opacity: 0 }); var t1; function expand() { clearTimeout(t1); //theSpan.find('a').addClass("selected"); theMenu.stop().show().animate({ height: tarHeight, opacity: 1 }, 200); } function collapse() { clearTimeout(t1); t1 = setTimeout(function () { // theSpan.find('a').removeClass("selected"); theMenu.stop().animate({ height: 0, opacity: 0 }, 200, function () { $(this).css({ display: "none" }); }); }, 250); } theSpan.hover(expand, collapse); theMenu.hover(expand, collapse); }); } 

I wrote a jquery drop-down menu, where the drop-down content displays the content of the mouse hovering in the navigation

JQ can Write Less ).
In addition, there is a problem in writing that way, that is, you can quickly shake a few times back and forth with the cursor on the menu. When you move the light mark, you will find that the drop-down menu is still on it.
Therefore, you must add a stop before the effect.
$ (Function (){
$ ('. Meun'). hover (function () {$ (this). find ('ul '). stop (true, true). slideDown ();},
Function () {$ (this). find ('ul '). stop (true, true). slideUp ('save ');
})
})

JS mouse hover drop-down box menu effect problems

To see the results, you must use a browser to browse the results. In addition, you must introduce the corresponding jquery library.

Related Article

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.