简单教程
提交运行
代码编辑器:
<script> function displayResult(){ var x=document.getElementById("button1").name; alert(x); } </script> <form> <input type="button" onclick="displayResult()" id="button1" name="button1" value="显示名称"> </form>
运行结果: