Created
July 22, 2013 00:50
-
-
Save WenLiangTseng/6050606 to your computer and use it in GitHub Desktop.
jQuery 去除一個元素本身的 HTML Tag
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
$('b').contents().unwrap(); | |
//For the greatest performance, always go native: | |
var b = document.getElementsByTagName('b'); | |
while(b.length) { | |
var parent = b[ 0 ].parentNode; | |
while( b[ 0 ].firstChild ) { | |
parent.insertBefore( b[ 0 ].firstChild, b[ 0 ] ); | |
} | |
parent.removeChild( b[ 0 ] ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment