.prepend()

.prepend() Method

  • Method used to insert content to the beginning of the selected elements (as the first child)

Example

$(() => {
  $('#prependParagraph').click(() => {
    // prepend a new paragraph to list of paragraphs
    const newParagraph = "<p class='one'>One</p>"
    $('.numbers').prepend(newParagraph)
  })
})

JS Bin on jsbin.com