-
获取双标记元素的值(.innerHTML)
var a=document.getElementById("aaa").innerHTML;
<script>
function aa() {
var a = document.getElementById("aaa").innerHTML;
alert(a);
}
</script>
<div id="aaa">放假了</div>
<button onclick="aa()">点一下试试</button>
点击按钮,改变标记里的值
<script>
function aa() {
var a = document.getElementById("aaa").innerHTML="<h1>哈哈哈哈哈哈</h1>";
}
</script>
<div id="aaa">放假了</div>
<button onclick="aa()">点一下试试</button>
-
获取单标记元素的值(.value)
var value = document.getElementById("uname").value;