x
 
<!DOCTYPE html>
<html>
<body>
<p>单击输入按钮可显示其 name 属性的值。</p>
<input type="button" onclick="myFunction()" id="myBtn" name="myname" value="试一试">
<p id="demo"></p>
<script>
function myFunction() {
  var x = document.getElementById("myBtn").name;
  document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>