jQuery的我怎么用Ajax加载的内容互动? [英] jQuery how do I interact with ajax loaded content?

查看:115
本文介绍了jQuery的我怎么用Ajax加载的内容互动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功地通过使用

jQuery(".menu li a").click( function(event){

    jQuery("#loadingArea").load(this.href)

});

被加载的内容

之后,我在我的网页新元素。我曾尝试申请jQuery的操作(做什么,当我点击或悬停鼠标),和要素没有响应。

After the content is loaded, I have new elements in my page. I have tried to apply jQuery manipulation (do something when I click or hover the mouse), and the element does not respond.

请给我解释一下为什么我无法触发已通过AJAX加载内容的事件?

Please explain to me why I am unable to trigger events in content that has been loaded through ajax?

请问方法.load()有事情做与此(即,如果我用$就我将能够与这些内容进行交互)?

Does the method .load() has something to do with this (i.e. if I had used $.ajax I would be able to interact with such content)?

感谢您,

推荐答案

.live()的回答你的问题:

http://api.jquery.com/live/

从文档:

的.live()方法能够影响尚未被元件   处理程序绑定:通过使用事件代表团加入到DOM   祖代元素负责所触发的事件   它的后代。传递给.live处理程序()永远不会绑定到一个   元件;相反,.live()绑定一个特殊的处理程序的根   DOM树。

The .live() method is able to affect elements that have not yet been added to the DOM through the use of event delegation: a handler bound to an ancestor element is responsible for events that are triggered on its descendants. The handler passed to .live() is never bound to an element; instead, .live() binds a special handler to the root of the DOM tree.

这篇关于jQuery的我怎么用Ajax加载的内容互动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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