Add Div Dynamically using JQuery

后端 未结 5 681
庸人自扰
庸人自扰 2021-02-13 09:54

I\'m not sure if this would be the best option.. But I want the option that when the user clicks a button, it will add another div or li.

I am going to allow users to u

5条回答
  •  遇见更好的自我
    2021-02-13 10:26

    You can add a new element to an existing parent like so:

    select the element to added the new

    /
  • to and use .append()

    $("#id").append("
    foo
    ");

    http://api.jquery.com/append/

    Alternatively, you can use the .html()

    http://api.jquery.com/html/

提交回复
热议问题