再会
我正在使用 wordpress,我有这个烦人的空段落标签
在我的 div 元素之一下方。
现在页面上还有很多其他的空白段落我不想删除,只有这个..
这是HTML:
<div class="wpcol-one-quarter">
<p><a rel="slb_group[803] slb slb_internal" href="http://asksomeone.co.za/wp-content/uploads/2013/03/boltmaster1.jpg"><img alt="boltmaster" src="http://asksomeone.co.za/wp-content/uploads/2013/03/boltmaster1-300x200.jpg" width="180" height="120" /></a></p>
</div>
<p> </p> <!--The culprit!!-->
<div class="wpcol-one-quarter">
<p><a rel="slb_group[803] slb slb_internal" href="http://asksomeone.co.za/wp-content/uploads/2013/03/trackmaster.jpg"><img alt="trackmaster" src="http://asksomeone.co.za/wp-content/uploads/2013/03/trackmaster-300x200.jpg" width="180" height="120" /></a></p>
</div>
<div class="wpcol-one-quarter">
<p><a rel="slb_group[803] slb slb_internal" href="http://asksomeone.co.za/wp-content/uploads/2013/03/multimaster.jpg"><img alt="multimaster" src="http://asksomeone.co.za/wp-content/uploads/2013/03/multimaster-300x200.jpg" width="180" height="120" /></a></p>
</div>
<div class="wpcol-one-quarter wpcol-last">
<p><a rel="slb_group[803] slb slb_internal" href="http://asksomeone.co.za/wp-content/uploads/2013/03/facemaster1.4.jpg"><img alt="facemaster1.4" src="http://asksomeone.co.za/wp-content/uploads/2013/03/facemaster1.4-300x200.jpg" width="180" height="120" /></a></p>
</div><div class="wpcol-divider"></div>
现在我计划通过以下方式删除它:
<script type="text/javascript">
jQuery(function($){
var pathname = window.location.pathname;
if(pathname == '/803-2'){
$('div.wpcol-one-quarter').next(){
$('p').each(function() {
var $this = $(this);
if($this.html().replace(/\s| /g, '').length == 0)
$this.remove();
});
}
}
});
</script>
为什么它不起作用?
谢谢你