Metoda jQuery replaceAll()
Przykład
Zastąp wszystkie elementy <p> elementami <h2>:
$("button").click(function(){
$("<h2>Hello world!</h2>").replaceAll("p");
});
Definicja i użycie
Metoda replaceAll() zastępuje wybrane elementy nowymi elementami HTML.
Składnia
$(content).replaceAll(selector)
Parameter | Description |
---|---|
content | Required. Specifies the content to insert (must contain HTML tags) |
selector | Required. Specifies which elements to be replaced |
Spróbuj sam - przykłady
Jak zastąpić każdy element <p>, który jest ostatnim dzieckiem swojego rodzica, elementem <span>.