Note that there are some explanatory texts on larger screens.

plurals
  1. POSlide up and remove submenus with jQuery
    text
    copied!<p>here is the code in question:</p> <pre><code> $('a.delete').click(function(e) { e.preventDefault(); var parent = $(this).parent(); $.ajax({ type: 'get', url: 'deletemenu.php', data: 'ajax=1&amp;delete=' + parent.attr('id').replace('menu-',''), beforeSend: function() { parent.animate({'backgroundColor':'#fb6c6c'},300); }, success: function() { parent.slideUp(300,function() { parent.remove(); }); $('.menusub').slideUp(300,function() { $('.menusub').remove(); }); } }); }); </code></pre> <p>Ok, what i want to do is slideUp and remove all submenu's which are under a specific menu (when deleting this menu). Right now i have <code>$('.menusub').slideUp(300,function() { $('.menusub').remove(); });</code>. To achieve this. The problem with this code, ofcourse, is that it will make all submenu's (which have the menusub class) disappear. How can i make sure that only the submenu's under the specific menu will disappear?</p> <p>By the way, this is the code to view the menu's</p> <pre><code> $result = mysql_query("SELECT * FROM Menu") or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo '&lt;div class="menu" id="menu-',$row['menu_id'],'"&gt;'; echo $row['menu_name']. " - ". $row['menu_weight']. "&lt;a class='delete' href='?delete=".$row['menu_id']."'&gt; delete&lt;/a&gt;"; echo '&lt;/div&gt;'; $sub = mysql_query("SELECT * FROM SubMenu INNER JOIN Menu WHERE SubMenu.menu_id = Menu.menu_id AND Menu.Menu_id = ".$row['menu_id']."") or die(mysql_error()); while($subrow = mysql_fetch_array($sub)){ echo '&lt;div class="menusub" id="menusub-',$subrow['submenu_id'],'"&gt;'; echo "-- ".$subrow['submenu_name']." - ".$subrow['submenu_weight']."&lt;a class='deletesub' href='?deletesub=".$subrow['submenu_id']."'&gt; delete&lt;/a&gt;&lt;br/&gt;"; echo '&lt;/div&gt;'; } }` </code></pre> <p>Tnx for replying!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload