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;
本博有部分内容来自网络,如有问题请联系:hebeilijianghua@qq.com,并注明来自博客园。