How can I change a JS element to see if it is a node or an empty variable?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on what you mean by an empty variable.
If you mean it hasn’t had a value assigned, you can check for
undefinedOr if you know it has a value, and need to see if it is an element, you could do something like this:
Or if you need to verify that it is a type 1 element, you could do this:
This eliminates text nodes, attribute nodes, comments, and a bunch of others.