all
Using the all
method, you can get all elements on the page that match the CSS selector, and return an array containing these elements.
<script src="https://cdn.jsdelivr.net/gh/kirakiray/ofa.js@4.5.26/dist/ofa.min.js"></script>
<ul>
<li>I am 1</li>
<li>I am 2</li>
<li>I am 3</li>
</ul>
<script>
setTimeout(()=>{
$.all("li").forEach((item,index)=>{
item.text = `change item ${index}`;
});
},500);
</script>
Getting Child Elements
Instances also have an all
method, which can be used to select and retrieve child elements on the instance.
<script src="https://cdn.jsdelivr.net/gh/kirakiray/ofa.js@4.5.26/dist/ofa.min.js"></script>
<div id="target1">
<ul>
<li>I am 1</li>
<li>I am 2</li>
<li>I am 3</li>
</ul>
</div>
<script>
const tar = $("#target1");
tar.all("li").forEach((item,index)=>{
item.text = `change item ${index}`;
});
</script>