日期:2014-05-16 浏览次数:20353 次
$("span").each(function(){ var xx=$(this).html(); $(this).replaceWith(xx); })
<span>hi1<span>hi2hi2</span>hi1</span><span>hi3</span>
<div id="spnas">
<span>hi1<span>hi2hi2</span>hi1</span><span>hi3</span>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
alert( $('#spnas').text() ) //简单方法
alert( $('#spnas').html().replace(/<\/?span[^>]*?>/ig,"") ) //为保留其它标签
$('#spnas').html( $('#spnas').text() ) ); //重新设置HTML
</script>