Prepend () method definition and usage:
This method inserts the specified element at the beginning of the inside of the matching element.
The action of the Prepend () method is the same as the Prependto (), but it is syntactically different, although it looks the same in grammatical form.
Syntax structure:
$ (selector). prepend (content)
Parameter list:
Parameters |
Describe |
Content |
Specifies the possible values for the content that is being inserted: 1.HTML code-for example ("<div></div>"). 2. Existing elements-for example ($ (". Div1")). 3.function (index) function-defines the function that returns the enclosing element, and the index parameter receives the indexer position of the selector. |
Selector |
The matching element to be inserted into the content. |
Instance code:
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.51texiao.cn/" /><title>Ant Tribe</title><styletype= "Text/css">Div{Height:200px;width:200px;Border:1px solid Green;}</style><Scripttype= "Text/javascript"src= "Mytest/jquery/jquery-1.8.3.js"></Script><Scripttype= "Text/javascript">$ (document). Ready (function(){ $("Button"). Click (function(){ $("Div"). prepend ("content to be added"); })})</Script></Head><Body><Div>Before you add content:</Div><Button>Click to view Effects</Button></Body></HTML>
The original address is: http://www.51texiao.cn/jqueryjiaocheng/2015/0613/4050.html
The most original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=5284
jquery's Prepend () method