jQuery live 功能不起作用
除了我的 最后一个问题,我需要添加 .live()
功能,因为我动态添加内容
这就是我现在所拥有的
$('.PointsToggle').live('each',function() {
$this = $(this);
if ($this.text() == 'POINTS STATEMENT - AVAILABLE 7AM TOMORROW') {
$this.width(510);
} else {
$this.width(20);
}
})
,但这现在似乎不起作用
有什么想法吗?
谢谢杰米
Further to my last question I need to add in the .live()
function as i'm adding the content dynamically
This is what I have now
$('.PointsToggle').live('each',function() {
$this = $(this);
if ($this.text() == 'POINTS STATEMENT - AVAILABLE 7AM TOMORROW') {
$this.width(510);
} else {
$this.width(20);
}
})
But this doesn't seem to work now
Any ideas?
Thanks
Jamie
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于此类事情,您将需要 livequery 插件
For this sort of thing you will need the livequery plugin
您只能使用
.live()
绑定事件处理程序,而“每个”不是。这应该有效:You can only bind event handlers with
.live()
, which 'each' is not. This should work:我认为您可能想用“ var thisObject”替换“ $ this”:
I think you probably want to replace '$this' with a 'var thisObject':
您可以在像单击这样的事件中使用每个方法,这意味着您可以在像本示例中这样的事件主体中使用此方法,
我在单击事件中使用每个函数。
you can use each method in a event like click that mean which you can use this method in a body of a event like this
in this sample I use each function in a click event.