NodesRef: fields() method
Query the attributes of the selected node.
Syntax
Parameters
fields
A Record<string, boolean>, describing whether it is necessary to query the corresponding type of property.
The range of queryable property types is as follows, and values outside this range will be ignored:
-
attribute(optional)- Only custom attributes will be returned, attributes such as
id,class,style,datasetwill not be returned. - Attributes with values
null/undefined/functionwill not be returned. - The key of the returned value is in kebab case.
- Only custom attributes will be returned, attributes such as
-
class(optional) -
dataset(optional) -
id(optional) -
index(optional) -
query(optional)- The
SelectorQueryobject with this node as the root node- The query performed on this
SelectorQueryobject is limited to this node and its descendant nodes. - Calling
selectRoot()on thisSelectorQueryobject will return theNodesRefobject representing this node.
- The query performed on this
- The
-
tag(optional) -
unique_id(optional)
callback
A callback function, the query result will be returned as the parameter of the callback function. The callback function has two parameters:
The first parameter returns the query result.
- If the
NodesRefrepresents one single node, it returns aRecord<string, any>object containing the query result. If the node is not found, it returnsnull. - If the
NodesRefrepresents multiple nodes, it returns an array ofRecord<string, any>objects, each element in the array corresponds to the query result of a node. If no nodes are found, it returns an empty array.
The second parameter returns the status of the query (error message).
Return Value
Contains the SelectorQuery object for this task. Call exec() to execute the task.
Examples
Possible output;
Compatibility
LCD tables only load in the browser