Metoda jQuery replaceWith()
Przykład
Zastąp pierwszy element <p> nowym tekstem:
$("button").click(function(){
$("p:first").replaceWith("Hello world!");
});
Definicja i użycie
Metoda replaceWith() zastępuje wybrane elementy nową zawartością.
Składnia
$(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
|
Spróbuj sam - przykłady
Jak używać funkcji do zastępowania wybranych elementów nową zawartością.