我在该网站上走来走去,与此相关的各种问题,我找不到解决的办法。

每当我的范围“ specvalue”不包含数据时,我都尝试隐藏父div“行”

    <div class="container-fluid" id="itmSpecsTbl">
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Accuracy</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem1','')%></span> </div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Drive Type</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem2','')%></span> </div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Free Speed</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem4','')%></span> RPM</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Increments</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem5','')%></span> </div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Length</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem6','')%></span> In</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Length</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem7','')%></span> mm</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Max Air Consumption</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem8','')%></span> </div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Air Inlet (NPT)</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem37','')%></span> </div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Min Torque</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem9','')%></span> ft lb</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Max Torque</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem10','')%></span> ft lb</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Min Torque</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem11','')%></span> in lb</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Max Torque</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem12','')%></span> in lb</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Min Torque</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem13','')%></span> in oz</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Max Torque</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem14','')%></span> in oz</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Min Torque</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem15','')%></span> kgf cm</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Max Torque</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitem16','')%></span> kgf cm</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Capacity</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitemfi0073','')%></span> lbs</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Min Reach</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitemfi0103','')%></span> in</div></div>
 <div class="row" id="row"><div class="col-xs-6" align="left"><b>Max Reach</b> </div><div class="col-xs-6" align="right"><span id="specvalue"><%=getAttribute('item','127559','custitemfi0104','')%></span> in</div></div>
</div>


没有数据时,“ getAttribute”用于提取我的商品的数据。它是空白-没有空格,什么都没有。

我试过使用:empty,:blank

#specvalue:empty #row, #specvalue:blank #row { display: none; }


这让我无处可去,与jQuery相同

$("#specvalue:empty").parent().hide();


到目前为止,什么都没做,我什至尝试将脚本放置在<head>标记内,甚至在调用技术文档后放置在标记内。

您认为我需要更具体地介绍CSS吗?我认为它可以在其他示例中使用,但不适用于此示例。

最佳答案

我已经删除了重复的id="row"并将id="specvalue"替换为class="specvalue"。然后,通过一些简单的jQuery,我隐藏了所有具有空specvalue的行。

注意:请始终记住id在整个html页面中必须始终是唯一的!



$('.specvalue').each(function(i, v) {
  if ($(this).html() === '') {
    $(this).closest('.row').hide();
  }
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container-fluid" id="itmSpecsTbl">
  <div class="row">
    <div class="col-xs-6" align="left"><b>Accuracy</b>
    </div>
    <div class="col-xs-6" align="right"><span class="specvalue">A</span>
    </div>
  </div>
  <div class="row">
    <div class="col-xs-6" align="left"><b>Drive Type</b>
    </div>
    <div class="col-xs-6" align="right"><span class="specvalue"></span>
    </div>
  </div>
  <div class="row">
    <div class="col-xs-6" align="left"><b>Free Speed</b>
    </div>
    <div class="col-xs-6" align="right"><span class="specvalue">B</span> RPM</div>
  </div>
</div>

10-02 09:52