Javascript 空时使用jquery隐藏单元格(无内容)
我试图用jquery隐藏空单元格,但代码不起作用Javascript 空时使用jquery隐藏单元格(无内容),javascript,jquery,Javascript,Jquery,我试图用jquery隐藏空单元格,但代码不起作用 <script> jQuery(document).ready(function() { if(jQuery('.tabcontent_01_custom_property_fields').html()) { ( $("th:empty").text().length == 0) .css('display', 'none'); } }); jQuery(文档).ready(函数(){ if(
<script>
jQuery(document).ready(function() {
if(jQuery('.tabcontent_01_custom_property_fields').html())
{
( $("th:empty").text().length == 0) .css('display', 'none');
}
});
jQuery(文档).ready(函数(){
if(jQuery('.tabcontent\u 01\u custom\u property\u fields').html())
{
($($th:empty”).text().length==0.css('display','none');
}
});
任何提示都很好。您已经有了
:empty
选择器,这就足够了。参见工作小提琴:
HTML:
您甚至可以缩短JS:
jQuery(document).ready(function() {
( $(".table td:empty").css('display', 'none'));
});
为什么不干脆是
$(“th:empty”).css('display','none')
?或者$(“th:empty”).hide()
为什么不直接使用CSS:th:empty{display:none;}
?任何代码都不会给你带来好运。没有运气[当你不使用一些随机算法时:)]。计算机是愚蠢的。你应该确切地知道你想要他们做什么。我可能解释得不够好。如果在我想要整个被删除或不显示之间没有内容,我可能解释得不够好。在我想要整个被删除或不显示之间没有内容这就是它的作用,不是吗?
jQuery(document).ready(function() {
if(jQuery('.table').html())
{
( $("td:empty").css('display', 'none'));
}
});
jQuery(document).ready(function() {
( $(".table td:empty").css('display', 'none'));
});