我有一个div,其中包含一个段落标签和一些文本。我想去掉p标签但保留div中的文本。在jQuery中实现这个功能是否可行?
<div id="footright"><p>Circus</p></div>
<div id="footright"><p>Circus</p></div>
有很多方法可以做到这一点。我可能会选择:
$('#footright > p').contents().unwrap();
是的:
$('#footright').text($('#footright').text());
$( "#footright>p" ).replaceWith(function() { return $(this).contents(); });
你可以选择:
$('#footright > p').html("");