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