如何恢復(fù)刪除的 mousedown 事件
如何恢復(fù)刪除的 mousedown 事件
?var n ?= 0;
? ? //綁定事件
? ? $(".aaron:first").on('mousedown mouseup', function(e) {
? ? ? ? $(this).text( '觸發(fā)類型:' + ?(e.type) + ",次數(shù)" + ++n)
? ? ? ? ++n;
? ? })
? ? //刪除事件
? ? $("button:first").click(function() {
? ? ? ? $(".aaron:first").off('mousedown')
? ? });
2019-03-28
2018-10-27
var f2=function(e) {
??????? $(this).text( '觸發(fā)類型:' +? (e.type) + ",次數(shù)" +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( '觸發(fā)類型:' +? (e.type) + ",次數(shù)" +n)
??????? ++n;
??? }
??? $(".aaron:first").on('mousedown mouseup',f1)
2018-10-27
將事件函數(shù)賦值給一個變量,然后恢復(fù)時重新調(diào)用變量
2017-09-23
你好,jQuery沒有特定的API可以提供恢復(fù)綁定事件的函數(shù),
你可以把事件里的代碼封裝成一個函數(shù),需要恢復(fù)時,重新使用on()綁定事件,調(diào)用這個函數(shù)就可以了。
2017-09-02
請貼上代碼,不然無法分析問題