gpt4 book ai didi

javascript - .live() 的行为与 .bind() 不同

转载 作者:行者123 更新时间:2023-11-28 16:25:52 26 4
gpt4 key购买 nike

问完这个问题后:jQuery die() does not work 。我发现 live() 的行为似乎不像 bind()

我有以下行:

$('.produit').die().live('change',function(){ // the rest
$('.produit').live('change',function(){ // that did not work either

然后我将其更改为:

$('.produit').unbind('change').bind('change',function(){ // the rest

两条线有什么区别。

在此示例中,.produit 被动态添加到页面中。绑定(bind)是在 prepend() 之后完成的。

我使用的是 jQuery 1.4.2 和 IE7。

最佳答案

如果您使用 IE,则实时和 change 事件会出现问题

搜索可以解决此问题的livequery插件。

尝试将事件更改为 Click 事件,您会发现它有效。

区别在于Bind适用于Already In Page元素,而live适用于also+Future元素。

关于javascript - .live() 的行为与 .bind() 不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8038545/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com