<label id="userName" class ="regLabel">由4~20个字母或数字组成.不支持中文,不能以数字开头</label>
这是我的页面中的label标签,我用userName=document.getElementById('userName');
userName.innerHTML="该用户名可用";//不起作用
userName.style.color="Green";//起作用
但是还是不能改变它原来的值,

解决方案 »

  1.   

    userName.value="该用户名可用";//看看呢
    userName.style.bgcolor="Green";//看看或者
    userName.style.backgroud-color = "Green";看看
      

  2.   

    userName.style.color="Green";//起作用 可以设置它的样式但是不能改变它的内容,怪?
      

  3.   

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            function change(id) {
                if (id && document.getElementById) {
                    var item = document.getElementById(id);
                    item.innerHTML = 'Modified Label';
                }
            }
        </script>
    </head>
    <body>
    <label id='name' for='item'>Some label</label>
    <input id='item' type='button' value='Some value' onclick='change("name")' />
    </body>
    </html>
      

  4.   

    <asp:Label id="userName" class ="regLabel">由4~20个字母或数字组成.不支持中文,不能以数字开头 </asp:Label>
    试一下
      

  5.   

    alert(userName);
    看看userName是否为object
      

  6.   

    找到原因了啊,是因为我用了主题了有些脚本得放到body标签内才可以执行,我的情况这是这个样子的,不过还是要谢谢大家