<!DOCTYPE html>
<html>
<body>
<p>Click the input button to display the value of its name attribute.</p>
<input type="button" onclick="myFunction()" id="myBtn" name="myname" value="Try it">
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myBtn").name;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>