javascriptjquerycssjquery-uijquery-ui-menu

Jquery ui menu sublevel not displaying


I have a jqueryui menu,but its sublevel is not displaying.when we check the html using firebug the sublist is there .But on hover the sublist is not displaying.

<link href="../css/style.css" rel="stylesheet" type="text/css" >
<link href="../css/header.css" rel="stylesheet" type="text/css" >
<link rel="stylesheet" href="../css/jquery-ui-1.10.3.custom.min.css">
<script src="../js/jquery-1.9.1.js"></script>
<script src="../js/jquery-ui-1.10.3.custom.js"></script>

<script>
     $(function() {
        $( "#menu" ).menu();
     });
</script>
 <style>
.ui-menu { width: 150px; }
 </style>
<body>
 <table>
<tr>
    <td colspan="4">
        <?php include_once("header_ui.php"); ?>
    </td>
</tr>
<tr>
    <td colspan="3">

        <ul id="menu">
              <li><a href="#" id="mainlink">link 1</a></li>
                  <ul>
                      <li><a href="#">sublink 1</a></li>
                      <li><a href="#">sublink 2</a></li>
                      <li><a href="#">sublink 3</a></li>
                 </ul>
              <li><a href="#">link 2</a></li>
              <li><a href="#">link 3</a></li>
              <li><a href="#">link 4</a></li>
         </ul>

    </td>

</tr>
</table>  

main links are displaying but when we hover over mainlink 1,the sublinks are not showing


Solution

  • your li#mainlink1 closing tag goes before the submenu

    <li><a href="#" id="mainlink">link 1</a></li>
    

    you need to wrap submenu inside this li:

     <li><a href="#" id="mainlink">link 1</a>
         <ul>
             <li><a href="#">sublink 1</a></li>
             <li><a href="#">sublink 2</a></li>
             <li><a href="#">sublink 3</a></li>
         </ul>
    </li>