x
 
<!DOCTYPE html>
<html>
<body>
<p>更改电子邮件字段的电子邮件地址,然后单击下面的按钮。</p>
电子邮件:<input type="email" id="myEmail" value="billgates@example.com">
<p>请注意,当您更改电子邮件字段的值时,默认值不受影响。</p>
<button type="button" onclick="myFunction()">试一试</button>
  
<p id="demo"></p>
<script>
function myFunction() {
  var x = document.getElementById("myEmail");
  var defaultVal = x.defaultValue;
  var currentVal = x.value;
  
  if (defaultVal == currentVal) {
    document.getElementById("demo").innerHTML = "默认值和当前值相同:"
    + x.defaultValue + " 和 " + x.value
    + "<br>请更改电子邮件字段的电子邮件地址以查看差异!";
  } else {
    document.getElementById("demo").innerHTML = "默认值为:" + defaultVal
    + "<br>新的当前值是:" + currentVal;
  }
}
</script>
</body>
</html>