在jquery中将initiation EventHandler从.live更改为.on后,按钮操作不起作用
我现在正在使用jQuery的版本:jQuery-1.11.0.min.js 在从.live更改为.on之前,我使用jquery:1.6.1(其中允许使用.live) 此按钮的Html:在jquery中将initiation EventHandler从.live更改为.on后,按钮操作不起作用,jquery,Jquery,我现在正在使用jQuery的版本:jQuery-1.11.0.min.js 在从.live更改为.on之前,我使用jquery:1.6.1(其中允许使用.live) 此按钮的Html: <div class="start"><button>Start</button></div> 更改为1.11.0后,我有以下代码: $('#ifrform').get(0).setAttribute('action', 'Handler.ashx');
<div class="start"><button>Start</button></div>
更改为1.11.0后,我有以下代码:
$('#ifrform').get(0).setAttribute('action', 'Handler.ashx');
$.blueimp.fileupload.prototype._initEventHandlers.call(this);
var filesList = this.element.find('.row.files'), eventData = { fileupload: this };
filesList.find('.start button')
.live(
'click.' + this.options.namespace,
eventData,
this._startHandler
);
$('#ifrform').get(0).setAttribute('action', 'Handler.ashx');
$.blueimp.fileupload.prototype._initEventHandlers.call(this);
var filesList = this.element.find('.row.files'), eventData = { fileupload: this };
filesList.find('.start')
.on(
'click.' + this.options.namespace,
'button',
eventData,
this._startHandler
);
使用.live一切正常,但使用.on,单击按钮后没有任何操作和错误。Jquery 1.11强制使用委托。Live和On都不推荐使用。检查此链接。所以我建议你换个角度 示例用法如下:
$( "table" ).delegate( "td", "click", function() {
$( this ).toggleClass( "chosen" );
});
你的代码看起来不错。你检查控制台有没有错误?我猜问题在代码的其他地方。为什么在
点击中有一个点
。
?难道这不只是点击控制台没有返回错误,im搜索问题。