0
我正在一個網站上工作。基本上,我在我的網站上有兩個腳本。第一個腳本執行得很好。但是,第二個腳本不起作用。JQuery沒有被執行
基本上,我想要做的是,如果用戶點擊一個按鈕,頁面上的某些元素被隱藏而其他人被顯示。有問題的元素是表格(不是asp表格)。
這是代碼。
<script type="text/javascript">
function Open_Window()
{
window.open("DonationConfirmation.aspx")
}
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#PayPalButton1").click(function() {
$("#PayPalTableButton").show();
$("#DonationsTableButton").hide();
});
$("#GoogleButton1").click(function() {
$("#PayPalTableButton").hide();
$("#DonationsTableButton").show();
});
});
</script>
第一個腳本,就是功能Open_Window()
工作完美。
但是,用jQuery編寫的第二個腳本不起作用。
這裏是按鈕(以圖像的形式)和表格的代碼。
<asp:Image ID="PayPalButton1" runat="server" ImageUrl="Resources/Icons/PayPal.jpg" onmouseover="this.style.cursor = 'pointer';" Height="65px" Width="130px" />
<asp:Image ID="GoogleButton1" runat="server" ImageUrl="Resources/Icons/Google.jpg" onmouseover="this.style.cursor = 'pointer';" Height="65px" Width="130px" />
<table id="PayPalTableButton" runat="server" style="margin:auto; text-align:center; width:100%;">
<tr>
<td style="text-align:center; height:60px;">
//Code
</td>
</tr>
</table>
<table id="DonationsTableButton" runat="server" style="margin:auto; text-align:center; width:100%;">
<tr>
<td style="text-align:center; height:60px;">
//Code
</td>
</tr>
</table>
你是什麼意思,「不工作」?您是否使用了錯誤控制檯來查看代碼是否正在執行但錯誤?你有沒有向jquery包裝中拋出一個「警報」,看它是否正在執行?你有jQuery的加載?更多的細節 - 特別是在JavaScript領域將使這更容易回答。 – 2012-03-03 14:55:50
基本上,我的母版頁我有以下行: <腳本類型=「文/ JavaScript的」 SRC =「資源/ jquery.min.js」> 通過不工作,我說的是簡單每當我點擊任何兩個按鈕(即,PayPalButton1和GoogleButton1)時都不會發生任何反應。表格不隱藏/顯示。如果沒有發生點擊事件,所有內容都保持不變。 – Matthew 2012-03-03 14:58:29
我建議編輯該問題以包括該問題。但是,你需要調試你的腳本。我會建議在Firefox中運行,然後啓動Tools-> Developer Tools-> Error Console並查看發生了什麼。根據這個問題,我們無法判斷你的jQuery是否加載完成。你必須首先建立這個部分,然後我們可以幫助調試你所擁有的代碼。 – 2012-03-03 15:02:38