before() Method


The before() method is used to insert new content before the selected element.

The inserted content is placed outside the element.

This method is useful when adding labels, icons, or messages before elements.

This inserts content before the box element.

This adds a symbol before input fields.

Content can be inserted dynamically before elements.

before() Method Notes:

  • Inserts content outside element
  • Appears before selected element
  • Does not affect inner HTML
  • Useful for labels and messages