element: $("button").click(function(){ $("p").before("
Hello world!
"); }); [Try it Β»](#) * * * ## Definition and Usage The before() method inserts specified content before the selected elements. **Tip:** To insert content after the selected elements, use the [after()](#) method. * * * ## Syntax $(_selector_).before(_content,_ function _(index)_) | Parameter | Description | | :--- | :--- | | _content_ | Required. Specifies the content to insert (can contain HTML tags). Possible values: * HTML elements * jQuery objects * DOM elements | | function _(index)_ | Optional. A function that returns the content to insert. * _index_ - Returns the index position of the element in the set. | * * *  ## More Examples [before() - Create content via HTML, jQuery, and DOM](#) Insert content using the before() method. (#) How to use a function to insert content before selected elements. * * jQuery HTML/CSS Methods](#)
YouTip