Insertion Methods
Prepend

prepend

This prepend method allows you to either prepend an element or an HTML string to the beginning of each element in the collection. The first version of the method inserts an element before the first child of each element, while the second version appends an HTML string to the beginning of the inner HTML of each element.

// Prepend an element to the elements
prepend: function(element) {
  this.elements.forEach(function(el) {
    el.insertBefore(element, el.firstChild);
  });
  return this;
},
 
// Prepend an HTML string to the elements
prepend: function(html) {
  this.elements.forEach(function(el) {
    el.innerHTML = html + el.innerHTML;
  });
  return this;
}