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 '); }); } |