jQuery - List menu dropdown

Howdy everyone. :slight_smile: I’m trying to use jQuery to show a submenu of items when a main item is hovered on. My efforts have come close, but not quite what I want.

The behavior on Link 3 is what I’m wanting, but of course the way the sublinks are embedded you get the behavior you see on the other ones.

I attempted to write it with the links separately, but I’m getting nothing now.

If any of you jQuery ninjas could take a look and possibly point me in the right direction, I’d appreciate it!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
	#topmenu { margin: 0; padding: 0; clear: left;}
	#topmenu li {float: left; margin: 0 10px 0 0; padding: 0 10px 0 0;list-style:none;}
	#topmenu li a {display: block; padding 0; text-decoration: none;}
	ul.tabs {float: left; padding: 5px 0; position: absolute; display:none; width:500px;}
	ul.tabs li {display:inline; margin:0 10px 0 0;}
	ul.tabs li a {font-size: 12px; padding: 0;}	
	<script style="text/javascript">
	$(document).ready(function() {
		$('#topmenu li.item').hover(
			function() { 
				$('ul.tabs', this).show(); 
			function() { 
				$('ul.tabs', this).hide(); 
	<ul id="topmenu">
		<li class="item">
			<a href="##">Item 1</a>
			<ul class="tabs">
				<li><a href="##">SubItem 1.1</a></li>
				<li><a href="##">SubItem 1.2</a></li>
				<li><a href="##">SubItem 1.3</a></li>
		<li class="item">
			<a href="##">Item 2</a>
			<ul class="tabs">
				<li><a href="##">SubItem 2.1</a></li>
				<li><a href="##">SubItem 2.2</a></li>
				<li><a href="##">SubItem 2.3</a></li>
		<li class="item">
			<a href="##">Item 3</a>
			<ul class="tabs">
				<li><a href="##">SubItem 3.1</a></li>
				<li><a href="##">SubItem 3.2</a></li>
				<li><a href="##">SubItem 3.3</a></li>

Thanks mate, that worked! Now to figure out exactly why it worked. :stuck_out_tongue:

For anyone who’s interested, here’s the final code before I throw my real links back in: