JQuery Unbind and then bind

后端 未结 3 740
萌比男神i
萌比男神i 2020-12-11 13:03

I\'ve found lots of examples on this topic.. however, I do not fully understand. Does my logic seem correct? I have a div as button (class of .myClass) and I don\'t want i

3条回答
  •  情书的邮戳
    2020-12-11 13:30

    You could use namespaced events, with on(). bind() has been deprecated.

    var foo = function () { ... }
    
    if (myCount)
      $('.myclass').on('click.foo', foo)
    else
      $('.myclass').off('.foo')
    

提交回复
热议问题