我正在使用jQuery UI來增強兩個ASP.Net無線電。點擊時,我想改變用戶界面,當我用Chrome調試器完成時,它會按預期工作,直到函數結束時退出,然後調試器進入實際的jQuery源代碼,以及我的更改代碼得到恢復。到底是怎麼回事?jQuery函數在執行完成後跳入jQuery源代碼
功能是如下:
$('input:radio').change(function(e){
e.preventDefault();
var $this = $(this);
var uploadBox = $this.parent().parent().next();
var manualBox = $this.parent().parent().next().next();
if ($this.attr('id') == "<%= UploadRadioButton.ClientID %>"){
manualBox.hide();
uploadBox.show();
}
else{
uploadBox.hide();
manualBox.show();
}
}
);
(.toggle()不會因某種原因工作)
調試器進入這個片段jQuery的源的:
if (ret !== undefined) {
event.result = ret;
if (ret === false) {
event.preventDefault();
event.stopPropagation();
}
}
編輯: 我忘了提及的JavaScript坐在UserControl。
評論e.preventDefault();與/和再試一次? – dbf
@dbf仍然不起作用:( – Lee
我建議不要使用服務器端語言來生成JavaScript,而應該使用類和'[data - *]'屬性以及jQuery的['data'](http:// api .jquery.com/data)方法。 – zzzzBov