<form method="post" action="" id="myform"> <input type="button" value="submit"> </form> <script type="text/javascript"> function init(){ var submitBtn=document.querySelector("input[value=submit]"); submitBtn.addEventListener("click",function(){ var form=document.getElementById("myform"); alert(form.id); form.submit(); }) } init(); </script>