可视化作曲家添加 </p><p> 前后表,如何删除?



我已将Visual Composer添加到我的WordPress网站。通过添加表,在表的第一个跨度和最后一个跨度中都有一个神秘的< /p > < p >。我试过用这个代码删除它们,但没有成功:

jQuery("span:contains('</p><p>')").each(function(){
    console.log('p tag gevonden');
     var str = "</p><p>";
     jQuery(this).text(jQuery(this).text().replace(str,''));
});

来自我们的朋友在谷歌Chrome中的"inspect元素",这是html:

<td class="vc_table_cell"><span class="vc_table_content"></p><p>Stad</span></td>
<td style="font-size:14px;line-height:14px;" class="vc_table_cell" data-th="Beschikbaar"><span class="vc_table_content">Beschikbaar</p><p></span></td>

试试这个。获取跨度,循环浏览内容,删除任何'<p></p>'元素。

演示

$('span').contents().filter(function(){
    return this.tagName === 'P';
}).remove();

更新:看起来你的<p></p>实际上是文本,不像实际的元素那样工作。

$('span').contents().map(function(index, value){
    this.textContent = this.textContent.replace(/[#</p>]/g, '');
});

DEMO2

我用这个代码来修复错误:

jQuery("span").each(function(){
 jQuery(this).text(jQuery(this).html().replace('&lt;/p&gt;',''));
 jQuery(this).text(jQuery(this).html().replace('&amp;lt;p&amp;gt;',''));
 jQuery(this).text(jQuery(this).html().replace('&lt;',''));
});

最新更新