通过javascript更改ASP:TEXTBOX的背景色
我已经在我的aspx页面中声明了asp:textbox通过javascript更改ASP:TEXTBOX的背景色,javascript,asp.net,Javascript,Asp.net,我已经在我的aspx页面中声明了asp:textbox <asp:TextBox ID="txta" runat="server" size="12" value="123"></asp:TextBox> 当控件失去焦点时,将显示警报,但背景颜色不变 如何做到这一点 使用document.getElementById(“”).style.backgroundColor=“#FF0000” 您忘记了使用文档.getElementById(“”).style.backgr
<asp:TextBox ID="txta" runat="server" size="12" value="123"></asp:TextBox>
当控件失去焦点时,将显示警报,但背景颜色不变
如何做到这一点 使用
document.getElementById(“”).style.backgroundColor=“#FF0000”代码>
您忘记了使用文档.getElementById(“”).style.backgroundColor=“#FF0000”代码>
您忘记了.style
<head runat="server">
<title>My Page</title>
<script type = "text/javascript" >
function changeColor() {
document.getElementById('<%= txta.ClientID %>').backgroundColor="#FF0000";
alert( '<%= txta.ClientID %>');
}
</script>
</head>
txta.Attributes.Add("onblur", "changeColor();")