代码编辑器:
x
1
<h3>演示了如何访问 Email 字段</h3>
2
E-mail: <input type="email" id="myEmail" value="john@example.com">
3
<p>点击按钮获取 email 字段的邮箱地址</p>
4
<button onclick="myFunction()">点我</button>
5
<p id="demo"></p>
6
<script>
7
function myFunction() {
8
var x = document.getElementById("myEmail").value;
9
document.getElementById("demo").innerHTML = x;
10
}
11
</script>
12