2014-03-26 20 views
0

我不能得到這個非常簡單的代碼工作時,放入一個ASPX文件。jQuery工作在HTML頁面,但不是當我把它放在一個ASPX頁面

<script type="text/javascript"> 
$(document).ready(function(){ 
    $(".hide").click(function(){ 
    $("p").toggle("slow"); 
    }); 
}); 
</script> 

In the body: 

<p>If you click on the "Hide" button, I will disappear.</p> 
<input type="button" value="Hide" class="hide" /> 

我得到了jQuery的語法錯誤,線10338和預期的對象上的$(文件)。就緒(函數(){線。任何人能提供一些幫助?

+0

你能顯示整個aspx頁面的路徑?另外,這真的是一個aspx頁面?如果是這樣,爲什麼你不使用asp.net控件? –

+0

我一直在看FireFox控制檯,並得到錯誤:jquery HTTP/1.1 401未經授權。我認爲在這一點上我有一個比第一個假設更大的問題。這很奇怪,我只得到這個嘗試在ASPX頁面而不是HTML的jQuery。我正在使用IIS6,所以我將繼續解決問題.. –

回答

0

路徑jQuery的文件是不正確

如果你願意,你可以添加這樣說:

<script type="text/javascript" src="~/js/jquery-whateverversion.js"></script> 

或者

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> 

添加,使其計算從根文件夾

+0

謝謝......擺脫了第一個錯誤,但仍然收到錯誤「對象預計在行:$(document).ready(function() –

相關問題