我想在用戶點擊一個按鈕時調用一個JS函數。但是onclick事件並未被解僱。開發工具顯示我下面的錯誤:javascript onclick沒有點擊按鈕點擊
錯誤執行:
function (/*Event*/ e){
// summary:
// Handler when the user activates the button portion.
if(this._onClick(e) === false){ // returning nothing is same as true
e.preventDefault(); // needed for checkbox
}else if(this.type == "submit" && !this.focusNode.form){ // see if a nonform widget needs to be signalled
for(var node=this.domNode; node.parentNode/*#5935*/; node=node.parentNode){
var widget=dijit.byNode(node);
if(widget && typeof widget._onSubmit == "function"){
widget._onSubmit(e);
break;
}
}
}
}
ReferenceError
arguments: Array[1]
get message: function() { [native code] }
get stack: function() { [native code] }
set message: function() { [native code] }
set stack: function() { [native code] }
type: "not_defined"
__proto__: Error
這裏是我的代碼:
HTML
<td>
<button dojoType = "xwt.widget.form.TextButton" id = "pingButton" baseClass = "defaultButton" onclick = "onPing();">Ping
</button>
</td>
JS:
onPing : function() {
alert('works');
}
任何sugges怎麼辦?
將'type =「button」'添加到''中,因爲代碼檢查'type'屬性。 –
什麼都沒有。即使在我的中添加類型後,同樣的錯誤即將出現 – Kany
廢話......應該說'type =「submit」' –