当前位置:网站首页>What do the values 1, 2, and 3 in nodetype mean?
What do the values 1, 2, and 3 in nodetype mean?
2022-08-01 07:29:00 【Front end cutter Zz】
Question:

There is such a sentence in the source code of the viewer.js plugin (as abovepicture), what does it mean?
if (!element || element.nodeType !== 1) {throw new Error('The first argument is required and must be an element.');} Parse:
All node types in JavaScript inherit from the Node type, so all node types share the same basic properties and methods.Each node has a nodeType property that indicates the type of node.
ThenodeType property returns the node type of the selected node, which allows us to know and distinguish each node in the document.
Syntax:
elementNode.nodeTypeReturn value: String value, representing the node type of the node.
The nodeType attribute has a total of 12 values (1~12), corresponding to different nodes.The node type is represented by the following 12 constants defined in the Node type, any node type must be one of them:

Example:
alert(Node.DOCUMENT_NODE); //9alert(document.nodeType == Node.DOCUMENT_NODE)span>; //true, not valid in IEalert(document.nodeType == 9); //true for all browsing边栏推荐
猜你喜欢
随机推荐
LeetCode 415:字符串相加
好的plm软件有哪些?plm软件排行榜
Zero-code website development tool: WordPress
我说过无数遍了:从来没有一种技术是为灵活组合这个目标而设计的
Fist game copyright-free music download, League of Legends copyright-free music, can be used for video creation, live broadcast
Go 支持 OOP: 用 struct 代替 class
Data Analysis 6
图像基本操作的其他内容
三维坐标系距离
Generate pictures based on the content of the specified area and share them with a summary
搜索框字符自动补全
Golang:go模版引擎的使用
Chapters 6 and 7 of Huawei Deep Learning Course
pytest接口自动化测试框架 | parametrize源码解析
Golang: go open web service
LevelSequence源码分析
pytest接口自动化测试框架 | parametrize叠加使用
Create, modify and delete tables
如何使用Photoshop合成星轨照片,夜空星轨照片后期处理方法
"By sharing" northwestern university life service | | bytes a second interview on three sides by HR









