Html
<p class="HiddenLine gray3">
<span>国有企业</span><span class="verticalLine">|</span>
<span>1001人以上</span><span class="verticalLine">|</span>
<span class="emptySpan"><font>饮料制造</font>行业</span>
<span class="verticalLine">|</span><span>南宁</span></p>
Js
//emptySpan
$(".emptySpan font").each(function () {
var _thisFont = $(this);
if ($.trim(_thisFont.text()) == "") {
_thisFont.parent().text("").css({ "width": 0, "height": 0, "overflow": "hidden" });
}
});
//隐藏‘|’
$(".HiddenLine").each(function () {
var $this = $(this);
var len = $this.find("span").length;
var firstSpanText = $.trim($this.find("span:eq(0)").text());
if (firstSpanText == "") {//如果第一个span为空
for (var j = 0; j < len; j++) {
if ($.trim($this.find("span:eq(" + (j * 2) + ")").text()) == "") {
$this.find("span:eq(" + (j * 2 + 1) + ")").hide();
}
}
}else {//第一个span不为空
for (var j = 1; j * 2 < len; j++) {
if ($.trim($this.find("span:eq(" + (j * 2) + ")").text()) == "") {
$this.find("span:eq(" + (j * 2 - 1) + ")").hide();
}
}
}
});