为什么我的jquery菜单不起作用?

时间:2017-02-20 05:27:54

标签: jquery-ui

我仔细检查了代码,但我发现它没有任何问题。 我在菜单here之后对其进行了建模,但这并不适合我。基本上,所有出现的是你的磨机ul。

 <!DOCTYPE html>
    <html>
    <head>
    
      <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
      <link rel="stylesheet" href="/resources/demos/style.css">
      <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
      <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
      <script type ="text/javascript">
    	
    		<!-- Dropdown menu -->
    		  <script>
    		$( function() {
    		$( "#dropMenu" ).menu();
    		} );
    	</script>
    <style>
    
    	.ui-menu { width: 150px; }
    	body{
    	
    		background-image: url("background.jpg");
    		background-repeat: no-repeat;
    		background-size: cover;
    	
    	}
    	h1{
    	
    		font-family:"Lucida Calligraphy","Lucida Fax", Arial;
    		color: Beige;
    		text-align:center;
    	
    	}
    	#footer{
    	
    		position: absolute;
    		bottom: 0;
    		background-color: rgba(20,90,50,.8);
    		margin-bottom: 0px;
    		padding-bottom: 0px;
    		border-radius:10%;
    		text-align:center;
    		color:beige;
    		margin-bottom: 0px;
    	
    	
    	}
    	#square{
    	
    		height:200px;
    		width: 350px;
    		background-color:rgba(20, 90,50);
    	
    	}
    	#wrapper{
    	
    		background-color: rgba(20, 90,50, .5);
    		margin: auto;
    		border-radius:6%;
    	
    	}
    </style>
    </head>
    <body>
    
    	<div id="wrapper"> 
    
    		<h1>Serenity Landscaping <br /> and Property Management</h1>
    		<!-- <div id="square"></div>  -->
    			<ul id="menu">
    				<li><div>Menu</div>
    				<ul>
    					<li><div>Home</div></li>
    					<li><div>Side Biz</div></li>
    					<li><div>Portfolio</div></li>
    					<li><div>Contact Us</div></li>
    				</ul>
    				</li>
    			</ul>
    	
    		
    		<div id="footer"><p>SLPM is owner operated and is dedicated to providing the highest quality service to all customers.
    		<br/>Services in the landscape and property maintenance field</p></div>
    	
    	</div>
    	
    	<script type ="text/javascript">
    	
    		var windowWidth=$(window).width();
    		var wrapperWidth=(windowWidth/2);
    		var windowHeight=$(window).height();
    		var wrapperHeight=windowHeight;
    		$("#wrapper").height(wrapperHeight+"px");
    		$("#wrapper").width(wrapperWidth+"px");
    		
    		<!-- footer width resizing -->
    		var footerWidth;
    		footerWidth = $("#footer").css("width", wrapperWidth);
    		<!-- footer width resizing -->
    		
    		<!--alert(wrapperWidth);-->
    		<!--alert(windowWidth);-->
    	</script>
    
    </body>
    </html>

1 个答案:

答案 0 :(得分:0)

我看到的第一个问题是您使用错误的id初始化菜单。

我为你的代码创建了一个小提琴并进行了一些小改动,它运行正常。

只有愚蠢的错误。

这是工作小提琴。

Working Fiffle