[html]Bootstrat dropdown menu while hover

2019-3-11 写技术

In order to display the dropdown menu while hover the nav, I add some scripts like this:

		function isMobile(){
			if (navigator.userAgent.match(/Android/i) || navigator.userAgent.indexOf('iPhone') != -1 || navigator.userAgent.indexOf('iPod') != -1 || navigator.userAgent.indexOf('iPad') != -1) {
				return true;
			}
			else {
				return false;
			}
		}	
	
		$(function(){
	
			if(!isMobile()) {
				$(document).off('click.bs.dropdown.data-api');
				$('li.dropdown').mouseover(function() {
					$(this).addClass('open');
				}).mouseout(function() {
					$(this).removeClass('open');
				});
			}
			
		});

 

It may need some style:

li.dropdown.open .dropdown-menu{display:block;}

 

标签: html

发表评论:

Powered by anycle 湘ICP备15001973号