Implement bootstrap navigation bar clickable and mouse hover display Pull-down Menu

Source: Internet
Author: User

When using the bootstrap navigation bar component, if your navigation bar has a drop down menu, the navigation of the Drop-down menu will only emerge from the Drop-down menu when clicked, and its href attribute will fail, that is, the hyperlink function is lost, which is not what I want, I want the navigation bar link to open its link normally, but also need to pull down the menu function, start tossing ~

First of all to solve the Pull-down menu can click the Navigation bar, the Drop-down menu effect is JS implementation, analysis Bootstrap.js file found, bootstrap the Drop-down menu written a jquery plug-in, in the dropdown code section found a key sentence:?

1 2 3 4 5 6 7 8 APPLY to STANDARD DROPDOWN ELEMENTS//=================================== $ (document). On (' Click.bs.drop Down.data-api ', Clearmenus). On (' Click.bs.dropdown.data-api ', '. Dropdown form ', function (e) {e.stoppropagation ( ). On (' Click.bs.dropdown.data-api ', toggle, Dropdown.prototype.toggle). On (' Keydown.bs.dropdown.data-api ' , toggle + ', [Role=menu] ', Dropdown.prototype.keydown)

Find a few key code, think of the solution, as long as the Click.bs.dropdown.data-api event closed on the OK, the code is as follows:?

1 2 3 $ (document). Ready (function () {$ (document). Off (' Click.bs.dropdown.data-api ');});

The above code test is effective, navigation bar can be clicked to solve, the following resolution mouse hover pop-up menu problem, this relatively simple, with jquery mouse events can be achieved, the code is as follows:?

1 2 3 4 5 6 7 8 9 10 11 12 13 14-15 16 $ (document). Ready (function () {dropdownopen ();//Call});        /** * mouse across on the expansion of the submenu, to avoid the need to click to expand * * Function Dropdownopen () {var $dropdownLi = $ (' Li.dropdown ');      $dropdownLi. MouseOver (function () {$ (this). addclass (' open ');      }). mouseout (function () {$ (this). Removeclass (' open '); }); }

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.