【问题标题】:issue when Upgrading to jQuery 1.5.1升级到 jQuery 1.5.1 时的问题
【发布时间】:2011-02-28 10:43:05
【问题描述】:

当我从 jquery 1.5 升级到 jquery 1.5.1 时,delete 链接不起作用:

演示:http://jsfiddle.net/EfsGN/

【问题讨论】:

    标签: jquery jquery-1.5


    【解决方案1】:

    这是 clone() 方法的错误,即 introduced in jQuery 1.5fixed in 1.5.1

    clone() 的默认行为应该是复制克隆元素的事件和数据,但是 1.5 不是这种情况(默认行为 strong> 复制事件)。

    要修复您的代码,请更改:

    $('#add-input').click(function() {
        main.append(clonedField.clone());
        return false;
    });
    

    $('#add-input').click(function() {
        main.append(clonedField.clone(true));
        return false;
    });
    

    工作小提琴:http://jsfiddle.net/EfsGN/7/

    【讨论】:

    • 谢谢你的回答。很有用。如果可以的话,我会给 100+。
    猜你喜欢
    • 2018-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多