2012-02-16 178 views
1

我有一个div,其中包含一个包含文本的段落标记。 我想要的是去除p标签,但保留文本在div?这是可能的jQuery中?如何删除一个div内的p标签?

<div id="footright"><p>Circus</p></div> 
+4

操纵与jQuery的DOM?是的,它*可能*是可能的。 – JJJ 2012-02-16 10:03:43

回答

1

是:

$('#footright').text($('#footright').text()); 
0
$("#footright>p").replaceWith(function() { return $(this).contents(); }); 
7

有很多方法可以做到这一点。我可能会一起去:

​$('#footright > p').contents().unwrap();​​​​​​​​​ 
-1

你可以去:

$('#footright > p').html("");