Insert content previous to each element in the set of matched elements.
HTML string, DOM element, array of DOM elements or Cheerio to insert before each element in the set of matched elements.
The instance itself.
$('.apple').before('<li class="plum">Plum</li>');$.html();//=> <ul id="fruits">// <li class="plum">Plum</li>// <li class="apple">Apple</li>// <li class="orange">Orange</li>// <li class="pear">Pear</li>// </ul> Copy
$('.apple').before('<li class="plum">Plum</li>');$.html();//=> <ul id="fruits">// <li class="plum">Plum</li>// <li class="apple">Apple</li>// <li class="orange">Orange</li>// <li class="pear">Pear</li>// </ul>
https://api.jquery.com/before/
Insert content previous to each element in the set of matched elements.