我如何使用jquery动态创建div或元素 [英] how to i access dynamically create div or elements with jquery

查看:72
本文介绍了我如何使用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){});

这篇关于我如何使用jquery动态创建div或元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆