<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool教程(w3cschool.cn)</title>
<script>
function displayResult(){
var x=document.getElementById("button1").name;
alert(x);
}
</script>
</head>
<body>
<form>
<input type="button" onclick="displayResult()" id="button1" name="button1" value="显示名称">
</form>
</body>
</html>