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.
我很好奇这样的事情是否可能
$('.parent').append('<div></div>', { text: 'delete', on: {click, dofunc(this)}})
这样做的关键是将事件处理程序绑定到其创建语句中新创建的元素,并将新创建的元素传递给处理函数。
是的,有可能。
$('<div/>', { text: 'delete', click: dofunc }).appendTo('.parent');
this在dofunc函数的上下文中是指被点击的元素。
this
dofunc
http://jsfiddle.net/e77L4/