gpt4 book ai didi

javascript - Jquery 与 Asp.net 按钮

转载 作者:行者123 更新时间:2023-11-28 20:34:33 24 4
gpt4 key购买 nike

我试图在 asp.net 按钮中触发 jquery。它没有被触发。出了什么问题?

//代码

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src ="Scripts/jquery-1.4.1.js"></script>
<script type ="text/javascript">
$(document.ready(function(){
$("#<%=Button1.ClientID %>").click(function () {
showalert('HTML Button Clicked');
});
});

function showalert(btnText) {
alert(btnText)
}
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Height="41px"
style="margin-left: 340px; margin-top: 197px"
Text="Button" Width="147px"/>
</div>
</form>
</body>
</html>

有人可以帮助我吗?

最佳答案

您的文档准备语法错误。试试这个代码

<script type ="text/javascript">

$(document).ready(function () {
$("#<%=Button1.ClientID %>").click(function () {

showalert('HTML Button Clicked');
});
});
function showalert(btnText) {
alert(btnText)
}
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Height="41px"
style="margin-left: 340px; margin-top: 197px"
Text="Button" Width="147px"/>
</div>
</form>
</body>
</html>

关于javascript - Jquery 与 Asp.net 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15698331/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com