当前位置:网站首页>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.nodeType
Return 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
边栏推荐
猜你喜欢
Image lossless compression software which works: try completely free JPG - C image batch finishing compression reduces weight tools | latest JPG batch dressing tools download
Practical training Navicat Chinese and English mode switching
Detailed explanation of the crawler framework Scrapy
第02章 MySQL的数据目录【1.MySQL架构篇】【MySQL高级】
Json对象和Json字符串的区别
LevelSequence源码分析
数据分析6
Introduction to the basic principles, implementation and problem solving of crawler
零代码网站开发利器:WordPress
华为深度学习课程第九章——卷积神经网络以及案例实践
随机推荐
Centos install php7.4, build hyperf, forward RDS
pytest interface automation testing framework | single/multiple parameters
华为深度学习课程第六、七章
【手撕AHB-APB Bridge】~ AHB地址总线的低两位为什么不用来表示地址呢?
旋度(7)连接失败localhost8080;连接拒绝了
LeetCode240+312+394
my creative day
Offer brush questions - 1
Upgrade to heavyweight lock, lock reentrancy will lead to lock release?
自制一款远程控制软件——VeryControl
app 自动化 打开app (二)
Golang: go static file processing
微信小程序请求封装
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
LabVIEW RT中的用户界面更新速度
The use of Golang: go template engine
22牛客多校1 C.Grab the Seat (几何 + 暴力)
I have three degrees, and I have five faces. I was "confessed" by the interviewer, and I got an offer of 33*15.
关于App不同方式更新的测试点归纳