开发者

What's a cross-browser way to check if a JavaScript variable is a <form> DOM object?

开发者 https://www.devze.com 2023-01-04 22:29 出处:网络
var form = document.createElement(\'form\'); (form.isDOMForm()) would evaluate开发者_JS百科 to true.You mean this:
var form = document.createElement('form');

(form.isDOMForm()) would evaluate开发者_JS百科 to true.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消