JS给html控件赋值

<html>
<head>
    <title> JS给html控件赋值 </title>
    <script language="javascript" type="text/javascript">
        window.onload = function setValue() {
            document.getElementById("s1").innerHTML = "信息";
            document.getElementById("s2").innerText = "信息";
            document.getElementById("s3").value = "信息";
        }
    </script>
</head>
<body>
    <span id="s1"></span>
    <span id="s2"></span>
    <input id="s3" name="s1" />
</body>
</html>

取值:var Label_text=document.getElementById('s1').innerHTML;

猜你喜欢

转载自www.cnblogs.com/lee24789229/p/9227971.html