代码之家  ›  专栏  ›  技术社区  ›  Renari

jQuery。从3.3开始,提交已被弃用。有什么替代方案?

  •  10
  • Renari  · 技术社区  · 8 年前

    通过检查源,您可以看到:

    /**
     * Bind an event handler to the "submit" JavaScript event, or trigger that event on an element.
     *
     * @param handler A function to execute each time the event is triggered.
     * @see {@link https://api.jquery.com/submit/}
     * @since 1.0
     * @deprecated 3.3
     */
    

    然而,jQuery博客中似乎没有提到这一点 here . 现在被标记为已弃用的替代方案是什么?

    3 回复  |  直到 5 年前
        1
  •  19
  •   void    8 年前

    您可以使用 .on

    $(selector).on("submit", callback)
    

    有关详细信息,请访问 http://api.jquery.com/on/

        2
  •  13
  •   Charlie Araya    6 年前

    我也在搜索这个,但在我的情况下,我想触发提交。在这种情况下,您可以通过触发事件来执行此操作:

    $(selector).trigger("submit")
    
        3
  •  1
  •   leopinzon    8 年前

    它没有被弃用,您可以在这里查看 .submit() API文件:

    https://api.jquery.com/submit/