我需要在下面的代碼中從「menu4」下拉菜單。代碼運行良好,但我需要引入一個下拉菜單。我嘗試過不同的方式在列表中有一個列表,但似乎不工作。我真的需要某人的幫助。任何人?謝謝。如何從document.getElementById下拉菜單javascript
document.getElementById("nav01").innerHTML =
"<ul id='menu'>" +
" <li><a href= '#'>Home</a></li> " +
" <li><a href= '#'>menu1</a></li> " +
" <li><a href= '#'>menu2</a></li> " +
" <li><a href = '#'>menu3</a></li> " +
" <li><a href = '#'>menu4</a></li> " +
" <li><a href = 'index.php'> Log Out</a></li> " +
"</ul>";
body {
font-family: Bookman Old Style;
font-size: 13px;
background-color:#EBF4FA;
color: #696969;
padding-right: 150px;
padding-left: 150px;
}
#top{
background-color: ;
height: 120px;
box-shadow: 10px #888888;
}
#main {
padding: 5px;
padding-left: 15px;
padding-right: 15px;
background-color: #EBF4F4;
border-radius: 0 0 5px 5px;
border-style: solid;
border-right-width: 1px;
}
h3 {
font-family: Bookman Old Style;
border-bottom: 3px;
color: black;
font-size: 16px;
}
table {
width:100%;
}
table, th , td {
border: 1px solid white;
border-collapse: collapse;
padding: 0px;
}
th {
text-align: left;
}
table tr:nth-child(odd) {
background-color: #ffffff;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
ul#menu {
padding: 0;
margin-bottom: 11px;
}
ul#menu li {
display: inline;
margin-right: 3px;
margin: 100px auto;
line-height:30px;
max-width:860px;
}
ul#menu li a {
background-color: #ffffff;
padding: 10px 20px;
text-decoration: none;
color: #696969;
border-radius: 4px 4px 0 0;
}
ul#menu li a:hover {
color: white;
background-color: black;
}
#footer {
position: right;
color: #ffffff;
}
h1 {
border-bottom: 3px solid orange;
font-size: 30px;
}
<!DOCTYPE html>
<html>
<head>
<title>About</title>
<link href="site.css" rel="stylesheet">
</head>
<nav id="nav01"></nav>
<body>
<div id="main">
<h1>About Us</h1>
<p>Dibon Company Limited is a project delivery and technical consultancy firm that provides efficient and cost effective methodologies and expertise in managing complex as well as simple projects</p>
<div class="box contactdetails">
<h2>Our Contact Details </h2>
<ul>
<li>Dibon Limited Company</li>
<li class="last">Website: <a href="https://www.dibon.co.ke">dibon</a></li>
<li>Email: [email protected]</li>
<li class="last">Facebook: <a href="https://web.facebook.com">Dibon</a></li>
</ul>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
而不是做這個'馬nual',如何使用框架中的模板功能(如angular.js)從數據生成下拉html代碼? – CodeToad