我在ASPX頁面中有一個scriptlet,如下所示。當我瀏覽到此頁面時,腳本調試器顯示「Micosoft JScript運行時錯誤:對象預期」。我在這裏標記了// < - 錯誤。我刪除了所有內容,只剩下$(function(){});它仍然抱怨對象預期。你知道爲什麼嗎?謝謝。Javascript Script Error:Object Expected
<fieldset>
<button id="Case5" name = "Case5" class="wizard" title="click here to select the case">
Case 5 - AAA </button><br />
<button id="Case6" name = "Case6" class="wizard" title="click here to select the case">
Case 6 - BBB </button><br />
</fieldset>
<script language="javascript" type="text/javascript">
$(function() { //<--error here
(":button").click(function() {
appendSelection(this);
});
});
function appendSelection(btn) {
//ToDo: append the selected value to the hyperlink
var caseNumber = btn.id;
switch (caseNumber) {
....
}
}
在的Site.Master腳本庫
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/jquery.bgiframe-2.1.1.js" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/ui/jquery.ui.datepicker.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/datetimepicker_css.js") %>" type="text/javascript" ></script>
<script src="<%: Url.Content("~/Scripts/lang/calendar-en.min.js") %>" type="text/javascript"></script>
<script src="<%: Url.Content("~/Scripts/json2.js") %>" type="text/javascript"></script>
<script type="text/javascript">var appRoot = '<%:Url.Content("~/")%>'</script>
<script src="<%: Url.Content("~/Scripts/MyApp.js") %>" type="text/javascript"></script>
你可能會錯過美元符號'前面( 「:按鈕」)'。 – Codo