Elementals.js

Latest Version: 2.0 RC 3 14 March 2017

Method _.nodeMask

Checks if the passed Element matches the passed mask or tagName.

Calling Convention:
_.nodeMask(Element[, nodeMask || tagName])
Parameters:
Element
The Element to test.
nodeMask optional

A bitwise mask used to filter the results. See the Node Masking page for more information.

If omitted, a mask of 1 (matching for nodeType 1) is used.

tagName optional
A tagName to match. When used instead of a nodeMask only elements of node type 1 with a matching tagName will be counted.
Returns:
Boolean true or false

Example

HTML

<div id="test"></div>

JavaScript

var test = document.getElementById('test');
console.log('#test is a Element node: ', _.nodeMask(test));
console.log('#test is a Comment node: ', _.nodeMask(test, _.NODEMASK_COMMENT));
console.log('#test is a DIV tag: ', _.nodeMask(test, 'div'));
console.log('#test is a UL tag: ', _.nodeMask(test, 'ul'));

Output

#test is a Element node: true
#test is a Comment node: false
#test is a DIV tag: true
#test is a UL tag: false