我如何使用jquery动态创建div或元素

问题描述:

我已经提出了ajax请求,得到的各行我将每个行都回显到一个动态创建的div中.现在,我想将事件绑定到每个div上,例如mousedown()..做一些事情,但是我无法访问任何div.请问有人可以帮我吗?

I have made a ajax request and the various rows gotten I echo each into a dynamically created the div. Now I want to bind a event to each of these divs like mousedown() .. do something but I am not able to access any of the divs. Please can any one help me with that?

如果您使用的是jQuery 1.7+,则应使用 .on() .delegate()作为

if your using jQuery 1.7+ you should use .on() or .delegate() as .live() is depreciated.

jQuery("table").on("click", "tr", function(event){});