如何使用jquery获取表映像以及如何检查映像是否可用?

如何使用jquery获取表映像以及如何检查映像是否可用?,jquery,Jquery,我有3*3矩阵表,每个表都有图像,但有一个是空的,因此如何使用JQUERY检查是否为空 如果($('td').children().length>0){ //做点什么 } 您可以使用length属性: $('table tr td').each(function() { if (!$(this).find('img').length) { console.log('This TD is empty') } }) 或: 或: $('table tr td').each

我有3*3矩阵表,每个表都有图像,但有一个是空的,因此如何使用JQUERY检查是否为空


如果($('td').children().length>0){
//做点什么
}

您可以使用
length
属性:

$('table tr td').each(function() {
   if (!$(this).find('img').length) {
       console.log('This TD is empty')
   }
})
或:

或:

$('table tr td').each(function() {
   if ($(this).is(':empty')) {
       console.log('This TD is empty')
   }
})
var $empty = $('table td:empty');
var $notEmpty = $('table td:not(:empty)');