Uncaught TypeError: .slideToggle is not a function

make sure, NOT to use the slim version of jquery, which excludes the effects like the animation.


Firstly ensure you're not using the 'slim' branch of jQuery as it does not include animation or AJAX functionality, amongst others. You will need to use the full version of jQuery in this instance.

In addition, items in your code will be a collection of Element objects, not jQuery objects, hence the slideToggle() function is not available on them.

To fix this you need to convert them:

$(items[i]).slideToggle();

Alternatively, you can convert all the logic to use jQuery, instead of the rather odd half/half solution you have now:

jQuery(function ($) {
  var $ul = $("#menu-footermenu");
  var $items = $("li");
  $items.filter(':gt(4)').hide();

  $('#morecat').click(function () {
    $items.filter(':gt(4)').slideToggle();
    $(this).hide();
  });
});