|
prepend()
Insert content at the beginning of each element in the set of HTML elements that match the selector of the script or of another query in the template (see query()). See also: append(). prepend(content)
Insert content as the first element to each element in the
set of HTML elements that match the selector of the script or of another query in the template (see query()). content HTML string, string or HTML string to insert after the matched elements. In case a plain text string is provided, it is automatically wrapped in a <span> element to avoid orphan text nodes to appear in the <body> element. ExamplesThis script inserts a heading as the first element in an element that has the ID
This script inserts a heading as the first element in an element that has the class
This script inserts content in multiple <div> elements at the same time.
This script prepends a snippet that contains the text "<h1>Personal information</h1>".
This script uses the function query() to find a box. Then it inserts a heading as the first element in that box.
This script uses the function query() to find a box, prepends a heading and sets the text color of the entire box to red.
Note: the way the functions prepend() and css() are used in this script is called 'chaining'. Chaining is optional; the same could be achieved by storing the result of the query in a variable:
|
|