Code has been added to clipboard!

Another Way to Hide an Element: jQuery .slideUp() Method

Reading time 1 min
Published Jan 16, 2018
Updated Oct 2, 2019

jQuery slideUp: Main Tips

  • The jQuery .slideUp() function hides an element with a slide up animation.
  • To reveal it with a slide down animation, use this method.

Usage of .slideUp() Method

The jQuery .slideUp() method conceals the specified element with a slide up animation.

In the example below, .slideUp() method is triggered by a hover event:

Example
$("button").hover(() => {
    $("img").slideUp();
});

The .slideUp() jQuery syntax is as follows:

$("selector").slideUp(length, easing, callback);

Let's review the three possible arguments:

  • length defines the animation's duration in milliseconds (400 by default). Keywords slow or fast can also be used for 600 and 200 ms.
  • easing defines if the speed of an animation is swing (default value) or linear.
  • callback specifies a function to fire after the slideUp jQuery animation.

Note: an element hidden by using jQuery slide up method will not be displayed at all, as if it was removed from the layout of the page.

Learn jQuery
Introduction
Selectors
Events
Event Methods
Download
Callback
Chaining
Get and Set
Add Element
Remove Element
Traverse
Parent
Children
Sibling Traverse
Filtering
jQuery AJAX
Effects
Show and Hide
Fade Effect
Slide Effect
Animate Effect
Manipulate CSS
Width and Height
.addClass()
.after()
.animate()
.append()
.appendTo()
.attr()
.before()
.bind() (deprecated)
.blur()
.change()
.click()
.clone()
.css()
.dblclick()
.delay()
.delegate() and .undelegate() (deprecated)
.detach()
.empty()
.end()
.error() (deprecated)
.fadeIn()
.fadeOut()
.fadeTo()
.fadeToggle()
.finish()
.focus()
.focusIn()
.focusOut()
.hasClass()
.height()
.hide()
.hover()
.html()
.innerHeight()
.innerWidth()
.insertAfter()
.insertBefore()
.keypress()
.keyup()
.live() and .die() (deprecated)
.load() (deprecated)
.mousedown()
.mouseenter()
.mouseleave()
.mousemove()
.mouseout()
.mouseover()
.mouseup()
.off()
.offset()
.offsetParent()
.on()
.one()
.outerHeight()
.outerWidth()
.position()
.prepend()
.prependTo()
.prop()
.proxy()
.queue()
.ready()
.remove()
.removeAttr()
.removeClass()
.removeProp()
.replaceAll()
.replaceWith()
.resize()
.scroll()
.scrollLeft()
.scrollTop()
.show()
.slideDown()
.slideToggle()
.slideUp()
.stop()
.submit()
.text()
.toggle()
.toggleClass()
.trigger()
.triggerHandler()
.unbind() (deprecated)
.unload() (deprecated)
.unwrap()
.val()
.width()
.wrap()
Event Properties
event.currentTarget
event.preventDefault()
event.relatedTarget
event.stopImmediatePropagation()
event.stopPropagation()
event.target
event.timeStamp
event.type
event.which
jQuery .find()
jQuery .keydown()
jQuery.noConflict()
pageY and pageX