问完这个问题后: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/