For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/lynx-api/selector-query.md.
Lynx
  • English
  • SelectorQuery BTS

    Gets a reference to the specified node in order to call its methods or get its properties.

    Depending on the method of creation, each SelectorQuery object will be assigned a root node. The scope of any node search will be limited to the leaf nodes of that node.

    Instance Methods

    SelectorQuery.exec()

    Execute all submitted UI node operation tasks.

    SelectorQuery.select()

    Select the first node that matches the specified CSS selector under the root node specified by SelectorQuery.

    SelectorQuery.selectAll()

    Select all nodes that match the specified CSS selector under the root node specified by SelectorQuery.

    SelectorQuery.selectRoot()

    Select the root node specified by SelectorQuery.

    SelectorQuery.selectUniqueID()

    Select nodes by specifying uid.

    Example

    Get the position and size of the specified text node:

    class Page extends Component {
      componentDidMount() {
        lynx
          .createSelectorQuery() // create SelectorQuery
          .select('#my-id') // Specify the selector of the target node
          .invoke({
            // Specify the operation for the target node
            method: 'boundingClientRect',
            success: function (res) {
              console.log(res);
            },
            fail: function (res) {
              console.log(res.code, res.data);
            },
          })
          .exec(); // Execute the query
      }
    
      render() {
        return (
          <view>
            <text id="my-id">...</text>
          </view>
        );
      }
    }

    Compatibility

    LCD tables only load in the browser

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.