【问题标题】:Hoe to rewrite this code to avoid jQuery click deprecated message?锄头重写此代码以避免 jQuery click deprecated 消息?
【发布时间】:2021-05-09 20:01:11
【问题描述】:

谁能告诉我如何重写这段 js 代码以避免 jqmigrate click deprecated 警告消息?

                    return $("<li/>").append($("<a/>", {
                        "class": item["class"],
                        text: item.text,
                        click: function (event) {
                            item.click.call(this, item, event);
                        }
                    }));

无论我如何重写这段代码,它总是告诉我 JQMIGRATE: jQuery.fn.click() 事件简写已被弃用

如果我关闭 JQMigrate,所有工作也正常。

【问题讨论】:

    标签: jquery click message deprecated


    【解决方案1】:

    答案是这样的

                return $("<li/>").append($('<a/>').attr("class", item["class"]).text(item.text).on('click', function(event){item.click(item,event);}));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-25
      • 1970-01-01
      • 2016-08-21
      • 1970-01-01
      • 2020-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多