Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 使用.replaceWith删除<;p>;标记,但将内容保留在标记内?_Jquery_Css_Html Table - Fatal编程技术网

Jquery 使用.replaceWith删除<;p>;标记,但将内容保留在标记内?

Jquery 使用.replaceWith删除<;p>;标记,但将内容保留在标记内?,jquery,css,html-table,Jquery,Css,Html Table,我有一个表单元格,其中包含用标记包装的内容: <td class=" address"><p> Content goes here </p></td> 尝试: 示例:(使用div代替td,但概念应相同) 说明: 获取段落标记内的元素(包括文本元素),然后调用这些文本元素,删除父p标记 $(function() { $("td.address > p").contents().unwrap(); }); 我会使用这个方法 从

我有一个表单元格,其中包含用
标记包装的内容:

<td class=" address"><p>
    Content goes here
</p></td>
尝试:

示例:(使用
div
代替
td
,但概念应相同)

说明:

获取段落标记内的元素(包括文本元素),然后调用这些文本元素,删除父
p
标记

$(function() {
    $("td.address > p").contents().unwrap();
});

我会使用这个方法


从DOM中删除匹配元素集的父元素,保留匹配元素。

@Ericmathewturano:没问题!很高兴为您提供帮助。很抱歉,由于意外单击而出现负面消息。
$('.address p').replaceWith('');
$('.address p').contents().unwrap();
$(function() {
    $("td.address > p").contents().unwrap();
});
$('.address p').replaceWith(function() {
    return $(this).html();
});
$('p').contents().unwrap();