API Documentation
ofa.js not only supports template syntax but also provides a rich API for direct DOM manipulation. Just like jQuery, you can replace verbose native JavaScript with concise ofa.js syntax to handle DOM operations effortlessly.
In the lifecycle functions and custom methods of a component or page module, you can call the APIs provided by ofa.js at any time to manipulate DOM elements flexibly and efficiently.
Instance Related
The core function in ofa.js, used to obtain and manipulate DOM element instances.
Get all child element instances of the current element.
Get the shadow root of the current element.
Get the previous sibling element of the current element.
Get all sibling elements before the current element.
Get the next sibling element of the current element.
Get all sibling elements after the current element.
Get all sibling elements of the current element.
Get the parent element of the current element.
Get all ancestor elements of the current element.
Clone the current element and its child elements.
Get the child element instance of the current element.
Get the root instance to which the current element belongs.
Get all child elements of the current element.
Get the web component host element to which the current element belongs.
Get the o-app component instance to which the current element belongs.
Node Operations
Add a child element to the current element.
Remove the last child element of the current element.
Remove the first child element of the current element.
Add the first child element to the current element.
Add or remove child elements of the current element.
Add a child element before the current element.
Add a child element after the current element.
Remove the current element.
Wrap the current element inside a specified element.
Remove the parent element wrapping the current element.
Attribute Operations
Get or set the text content of an element.
Get or set the HTML content of an element.
Get or set the attributes of an element.
Get or set the styles of an element.
Get the style object of an element.
Get the class list of an element.
Get or set the data attributes of an element.
Event Related
Add an event listener to an element.
Add a one-time event listener to an element.
Trigger a custom event on an element.
Remove an event listener from an element.
Others
The root component of an ofa.js application, used to manage application state and routing.
The page component of ofa.js, used to create single-page application pages.
Get form data.
Get the tag name of an element.
Get the index of an element within its parent element.
Check if an element matches a specified selector.
Refresh the current component or page.
Get the path of the current page.
Extend the functionality of ofa.js.
Get the version number of ofa.js.
Stanz is the reactive data feature of ofa.js, supporting automatic data updates.