【问题标题】:How to rewrite .removeAttribute to make it compatible with jquery 3.3.1?如何重写 .removeAttribute 以使其与 jquery 3.3.1 兼容?
【发布时间】:2019-08-30 07:45:55
【问题描述】:

fancybox 脚本的以下摘录在 jquery 3.3.1 下不起作用。它适用于 jquery 1.11.0。

如果没有 removeAttribute,您将如何重写此语句,这被报告为不是函数?

a.support.opacity || 
(p.get(0).style.removeAttribute("filter"), 
f.get(0).style.removeAttribute("filter"));

【问题讨论】:

  • 您是在寻找removeProperty 吗?
  • 我不知道 removeProperty 或 removeAttr 是否合适。但是这里的每个答案:stackoverflow.com/questions/14344289/…(朝向页面底部)必须替换该属性。我只是不明白他是如何处理语法的。
  • 假设a 是一个jQuery 对象,那么问题是support 的使用。文档建议改用 Modernizr 进行特征检测。
  • 为什么不升级到最新版本的fancybox?
  • 为什么你认为 removeAttribute 在 jquery 中被弃用了?这不是 jquery 方法,因为您使用了 .get(0).style(developer.mozilla.org/en-US/docs/Web/API/Element/…

标签: javascript jquery fancybox backwards-compatibility


【解决方案1】:

removeAttribute 的所有实例替换为 removeProperty.unbind.off 完全解决了这个问题。

旧脚本现在加载 jquery 3.3.1。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 2016-02-01
    • 2013-05-09
    • 2013-04-20
    • 2018-11-27
    • 1970-01-01
    相关资源
    最近更新 更多