$("#experiences tr")
For the above one,how to judge if it's empty or not?
对于上面这个,如何判断它是否为空?
I thought its boolean value should be false,but seems not.
我认为它的布尔值应该是假的,但似乎不是。
5 个解决方案
#1
47
use the length property:
使用长度属性:
$("#experiences tr").length
if it's 0 it's empty
如果它是0,它就是空的
#2
1
var experienceRows = $('#experiences tr'),
len = experienceRows.length;
if ( len ) {
} else {
}
#3
0
Or, if you just want to affect only the empty elements, use
或者,如果您只想影响空元素,请使用
$('#experiences tr:empty')
or the other way around:
或者反过来说:
$('#experiences tr:not(:empty)')
#4
0
$("#experiences tr:empty")
#5
0
//More Improved and Accurate - Trim white spaces as well
//Define
function trim(str) {
return( ("" + str).replace(/^\s+/,'').replace(/[\s]+/g,' ').replace(/\s+$/,'') );
}
//Call
if(trim(frmObj.element.value).length ==0) { //true }
#1
47
use the length property:
使用长度属性:
$("#experiences tr").length
if it's 0 it's empty
如果它是0,它就是空的
#2
1
var experienceRows = $('#experiences tr'),
len = experienceRows.length;
if ( len ) {
} else {
}
#3
0
Or, if you just want to affect only the empty elements, use
或者,如果您只想影响空元素,请使用
$('#experiences tr:empty')
or the other way around:
或者反过来说:
$('#experiences tr:not(:empty)')
#4
0
$("#experiences tr:empty")
#5
0
//More Improved and Accurate - Trim white spaces as well
//Define
function trim(str) {
return( ("" + str).replace(/^\s+/,'').replace(/[\s]+/g,' ').replace(/\s+$/,'') );
}
//Call
if(trim(frmObj.element.value).length ==0) { //true }