jQuery before() Metode
Voorbeeld
Voeg inhoud voor elke <p>-element in:
$("button").click(function(){
$("p").before("<p>Hello world!</p>");
});
Definisie en gebruik
Die before() metode voeg gespesifiseerde inhoud voor (voor) die geselekteerde elemente in.
Wenk: Om inhoud na geselekteerde elemente in te voeg, gebruik die after() metode.
Sintaksis
$(selector).before(content,function(index))
Parameter | Description |
---|---|
content | Specifies the content to insert (can contain HTML tags)
Possible values:
|
function(index) | Optional. Specifies a function that returns the content to insert
|
Probeer dit self - voorbeelde
Voeg inhoud in met die before() metode.
Hoe om 'n funksie te gebruik om inhoud voor geselekteerde elemente in te voeg.