🚨 Get Your Free NFT Certificate Mint by Completing the Web3 Exam! START NOW

Code has been added to clipboard!

jQuery .unwrap(): Remove Parents of HTML Elements

Reading time 1 min
Published Jan 24, 2018
Updated Oct 1, 2019

jQuery unwrap: Main Tips

  • jQuery .unwrap() removes parents of the selected HTML elements.
  • After you make jQuery remove parent elements, the function returns the unwrapped content.
  • The function opposite to unwrap jQuery offers is .wrap().

Using .unwrap()

The .unwrap() jQuery function removes ancestor elements of the matched elements.

$("button").click(() => {

To make jQuery remove parent elements, you don't need to define any arguments:


The following syntax sets a selector (defined in a string) to check the parent element against:


Remember: if the selector and parent do not match, unwrapping will not occur.