如何恢復刪除的 mousedown 事件
如何恢復刪除的 mousedown 事件
?var n ?= 0;
? ? //綁定事件
? ? $(".aaron:first").on('mousedown mouseup', function(e) {
? ? ? ? $(this).text( '觸發類型:' + ?(e.type) + ",次數" + ++n)
? ? ? ? ++n;
? ? })
? ? //刪除事件
? ? $("button:first").click(function() {
? ? ? ? $(".aaron:first").off('mousedown')
? ? });
2019-03-28
2018-10-27
var f2=function(e) {
??????? $(this).text( '觸發類型:' +? (e.type) + ",次數" +n)
??????? ++n;
??? };
??? var f2_json={
??????? 'mousedown':f2,
??????? 'mouseup':f2,
??? }
??? //刪除事件
??? $("button:eq(1)").click(function() {
??????? $(".aaron:last").off();
??? });
??? //重裝事件
??? $("button:last").click(function(){
??????? $(".aaron:last").on(f2_json);
??? });
2018-10-27
我就鄙視樓上了,難道jquery沒有api就不會操作了嗎?jquery也是人寫出來的啊,不懂得變通
2018-10-27
var n? = 0;
??? //綁定事件
??? var f1=function(e) {
??????? $(this).text( '觸發類型:' +? (e.type) + ",次數" +n)
??????? ++n;
??? }
??? $(".aaron:first").on('mousedown mouseup',f1)
2018-10-27
將事件函數賦值給一個變量,然后恢復時重新調用變量
2017-09-23
你好,jQuery沒有特定的API可以提供恢復綁定事件的函數,
你可以把事件里的代碼封裝成一個函數,需要恢復時,重新使用on()綁定事件,調用這個函數就可以了。
2017-09-02
請貼上代碼,不然無法分析問題