Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将事件附加到动态可编辑=真实列表_Javascript_Jquery_Dom - Fatal编程技术网

Javascript 将事件附加到动态可编辑=真实列表

Javascript 将事件附加到动态可编辑=真实列表,javascript,jquery,dom,Javascript,Jquery,Dom,我有下一张单子 <ul contenteditable="true"> <li>Some text</li> </ul> 它适用于预加载的列表,当我按enter键时,它会创建一个新元素,这没关系,但不适用于新的列表元素使用.delegate而不是.on 关于.on的jQuery文档 根据一组特定的根元素,将处理程序附加到与选择器匹配的所有元素的一个或多个事件上(现在或将来) 小心,签名上的.on与签名上的不同。代表使用! 有关更多详细信息,请

我有下一张单子

<ul contenteditable="true">
  <li>Some text</li>
</ul>
它适用于预加载的列表,当我按enter键时,它会创建一个新元素,这没关系,但不适用于新的列表元素使用.delegate而不是.on

关于.on的jQuery文档

根据一组特定的根元素,将处理程序附加到与选择器匹配的所有元素的一个或多个事件上(现在或将来)

小心,签名上的.on与签名上的不同。代表使用!
有关更多详细信息,请参阅。

现在代码看起来像$document.delegate'[contenteditable=true],'paste',函数e{//my actions to take};
$(document).on('paste','[contenteditable="true"]', function (e) {
  //my actions to take
});