category subcategory in drop down
Is possib开发者_如何学JAVAle to create category in the drop down menu using jquery? so it will be:
Southern Suburb
- suburb1
- suburb2
- suburb3
- suburb4
Nothern Suburb
- suburb5
- suburb6
thanks
This has nothing to do with jQuery or JavaScript. Use the HTML <optgroup>
tag to divide your list into different sections. For example:
<select>
<optgroup label="Southern Suburb">
<option value="1">suburb1</option>
...
</optgroup>
<optgroup label="Northern Suburb">
<option value="5">suburb5</option>
...
</optgroup>
</select>
Edit: This answer isn't relevant you were asking for a select menu not a navigation list...
To agree with casablanca, a dropdown would have another to do with jquery... (unless you were animating it)
Basically you could make a list with your elements then create a sub list within a list element of your first list (if you can follow that...)
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Contact-Type" content="text/html; charset=utf-8" />
<title>Dropdown</title>
<style type="text/css">
/* hide child elements */
#nav li ul {
display:none;
}
/* show child elements when hovering over list item */
#nav li:hover ul {
display:block;
}
</style>
</head>
<body>
<ul id="nav">
<li><a href="#">Southern Suburb</a>
<ul>
<li><a href="#">suburb1</a></li>
<li><a href="#">suburb2</a></li>
<li><a href="#">suburb3</a></li>
</ul>
</li>
</ul>
</body>
</html>
Good luck
精彩评论