我试图从javascript函数更改背景。颜色会变化,但立即返回其原始颜色。我做错了什么?谢谢
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">
<title></title>
<script type="text/javascript">
function acheck() {
document.body.style.backgroundColor = "yellow";
}
</script> </head>
<body>
<form id="form1" runat="server">
<div><p id="p2" >
<script> document.body.style.backgroundColor = "blue";
</script>
</p>
<asp:Button ID="Button1" runat="server" OnClientClick="acheck()" Text="Button" />
</div>
</form> </body> </html>
谢谢,我找到了一个简单的解决方案:
<asp:Button ID="Button1" runat="server" OnClientClick="acheck();return false;" Text="Button" />
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句