<input type='button' id='but' onclick='func()'> <script> function func() { alert('do') } document.getElementById('but').click() </script>