只用一个& nbsp;使用jQuery的空间 [英] Remove elements with only a   space using jQuery

查看:76
本文介绍了只用一个& nbsp;使用jQuery的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法去除这个

 < p> < / p为H. 

使用jQuery?

解决方案

试试:

  $('p')
.filter(function(){
return $ .trim($(this).text())===''&& $(this).children()。length == 0
})
.remove()

它会发现所有的< p> ; s没有任何内容,并将它们从DOM中移除。


Is there a way to remove this

<p> </p>

using jQuery?

解决方案

Try:

$('p')
    .filter(function() {
        return $.trim($(this).text()) === '' && $(this).children().length == 0
    })
    .remove()

What that does is it finds all the <p>s that have nothing in them, and removes them from the DOM.

这篇关于只用一个&amp; nbsp;使用jQuery的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆