Created
February 26, 2014 03:43
-
-
Save ituki/9223146 to your computer and use it in GitHub Desktop.
【jQuery】親要素を削除する ref: http://qiita.com/ituki_b/items/e519185cb48b182d04b1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<p>ここをクリックする</p> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('div p').click(function(){ | |
$(this).parent().remove(); //divとその中身が全て消えちゃう | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('div p').click(function(){ | |
$(this).unwrap(); //divだけを消す | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment