Metoda jQuery replaceWith().
Příklad
Nahraďte první prvek <p> novým textem:
$("button").click(function(){
$("p:first").replaceWith("Hello world!");
});
Definice a použití
Metoda replaceWith() nahradí vybrané prvky novým obsahem.
Syntax
$(selector).replaceWith(content,function(index))
Parameter | Description |
---|---|
content | Required. Specifies the content to insert (can contain HTML tags)
Possible values:
|
function(index) | Optional. Specifies a function that returns the content to replace
|
Zkuste si to sami - příklady
Jak používat funkci k nahrazení vybraných prvků novým obsahem.