zoukankan      html  css  js  c++  java
  • jQuery为什么移除了.toggle()方法

    原文

    The .toggle() method is provided for convenience. It is relatively straightforward to implement the same behavior by hand, and this can be necessary if the assumptions built into .toggle() prove limiting.

    For example, .toggle() is not guaranteed to work correctly if applied twice to the same element.

    Since .toggle() internally uses a click handler to do its work, we must unbind click to remove a behavior attached with .toggle(), so other click handlers can be caught in the crossfire.

    The implementation also calls .preventDefault() on the event, so links will not be followed and buttons will not be clicked if .toggle() has been called on the element.

    原文

    This is the "click an element to run the specified functions" signature of .toggle(). It should not be confused with the "change the visibility of an element" of .toggle() which is not deprecated. The former is being removed to reduce confusion and improve the potential for modularity in the library. The jQuery Migrate plugin can be used to restore the functionality.

  • 相关阅读:
    课堂例子验证
    大道至简第三章读后感
    动手动脑例子验证
    各数相加的思路、流程图、源代码及实现截图
    大道至简第二章读后感
    《大道至简》第一章读后感
    个人冲刺08
    个人冲刺07
    构建之法读后感04
    个人冲刺06
  • 原文地址:https://www.cnblogs.com/sevenskey/p/5526942.html
Copyright © 2011-2022 走看看