Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过javascript更改ASP:TEXTBOX的背景色_Javascript_Asp.net - Fatal编程技术网

通过javascript更改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

我已经在我的aspx页面中声明了asp:textbox

 <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();")