Here is the jquery I am testing:
var length = $('#showLBVRBVVol').length;
if(length != 0) {
console.log('test');
}
This throw an error of undefined
What is interesting is this works:
var length = $('#showLBVRBVVol').length;
if(length == 0) {
console.log('test');
}
The above will correctly log ‘test’. Is there something I am doing wrong that the first option is not working but the second one is?
The element is dynamically added if it is needed otherwise it doesn’t exist. I need to be able to tell the difference between the two.
EDITED:
I think you want check whether it exists or not, so to check existence of
'#showLBVRBVVol'elementif it exists then it will return 1 (boolean true) otherwise 0 (boolean false)