The code copy is as follows: function getid(id) { alert(id); } <input id="btn1" type="button" value="test" onclick="return getid(this.id)" />