2
var form = document.createElement('form');

(form.isDOMForm()) would evaluate to true.

1 Answer 1

6

You mean this:

var form = document.createElement('form');
alert(form.nodeName);

More Info:

http://www.howtocreate.co.uk/tutorials/javascript/dombasics

Note that you can also use tagName but nodeName seems to be a better choice.

Sign up to request clarification or add additional context in comments.

4 Comments

@Pekka, not always, it could be either upper or lowercase. Please read: ejohn.org/blog/nodename-case-sensitivity Other than that gotcha, yes, this is the way to do it.
I think that for HTML it is form.nodeName == "FORM" in all browsers. EDIT: what @Aistina said.
I would also convert it to (e.g.) uppercase before comparing, because I remember observing "FORM" string in firebug - probably case may vary
nodeName and tagName are precisely as good as each other in this situation where we know for certain that we're dealing with an element.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.