Metoda jQuery append() .

❮ jQuery HTML/CSS metody

Příklad

Vložit obsah na konec všech prvků <p>:

$("button").click(function(){
  $("p").append("<b>Appended text</b>");
});

Definice a použití

Metoda append() vloží určený obsah na konec vybraných prvků.

Tip: Chcete-li vložit obsah na začátek vybraných prvků, použijte metodu prepend() .


Syntax

$(selector).append(content,function(index,html))

Parameter Description
content Required. Specifies the content to insert (can contain HTML tags)

Possible values:

  • HTML elements
  • jQuery objects
  • DOM elements
function(index,html) Optional. Specifies a function that returns the content to insert
  • index - Returns the index position of the element in the set
  • html - Returns the current HTML of the selected element

Zkuste si to sami - příklady


Vložení obsahu pomocí metody append().


Pomocí funkce vložit obsah na konec vybraných prvků.


❮ jQuery HTML/CSS metody