jQuery prepend () method
Examples
In all <p> element at the beginning of Inserts:
$("button").click(function(){
$("p").prepend("<b>Prepended text</b>");
});
$("p").prepend("<b>Prepended text</b>");
});
try it"
Definition and Usage
prepend () method to insert the specified content at the beginning of the selected element.
Tip: To insert content at the end of the selected element, use append () method.
grammar
$(selector).prepend(content,function(index,html))
参数 | 描述 |
---|---|
content | 必需。规定要插入的内容(可包含 HTML 标签)。
可能的值:
|
function(index,html) | 可选。规定返回待插入内容的函数。
|
More examples
prepend () - Create content via HTML, jQuery and DOM
() Method to insert content via prepend.
Use pre-function content
Using the function at the beginning of the selected element insertions.