Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我该怎么做:
通过单击一个按钮应该在一个内部创建一个新按钮<div>
<div>
PS:每个新按钮都会从列表的位置访问数据
有谁知道逻辑错误在哪里?
您可能遇到的问题是为创建的按钮绑定事件点击
您应该使用该on()方法有 2 个实现on()。一种允许直接绑定到元素,但这些元素必须存在,并且不考虑期货。
on()
另一种方法是委托方法。您将处理程序委托给更高级别的元素或文档。此方法在事件冒泡时捕获事件
http://api.jquery.com/on/
i++您还必须在创建每个按钮时增加“i”值 =>
i++