text
This text method allows you to either set the text content of the elements in the collection or retrieve the text content of the first element in the collection. The first version of the method sets the text content of each element to the specified value, while the second version returns the text content of the first element.
// Set the text content of the elements
text: function(text) {
this.elements.forEach(function(element) {
element.textContent = text;
});
return this;
},
// Get the text content of the first element
text: function() {
return this.elements[0].textContent;
}