问题
I have an HTML like this.
<div class="wrapper">
<input class="myClass" ....>
</div>
I want to remove the wrapper div with class 'wrapper' so that the output will be.
<input class="myClass" ....>
Would be great if it is done with jquery.
回答1:
Use .unwrap(). Try this:
$('.wrapper').children().unwrap();
DEMO
回答2:
use .replaceWith() in jquery
$('.wrapper').replaceWith(function() {
return $('input ', this);
});
Fiddle
来源:https://stackoverflow.com/questions/22762279/css-jquery-how-to-remove-wrapper-div-element