Add Div Dynamically using JQuery

后端 未结 5 684
庸人自扰
庸人自扰 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:13

    Your example updated on jsFiddle

    $("input[type=submit]").click(function(){
        $("
  • ").html("item").appendTo("ul"); })
  • You can create elements using $("") and set attributes, add classes and so on. Then append where you want.

提交回复
热议问题