javascript - On button click run function that add stuff to body -


sorry noobish question, new html/javascript. lets have from:

<form id="pass" >         <p>             password: <input type="password" name="password" >             username: <input type="text" name="username" value="user">              <input type="submit" value="send" class=btn> <input type="reset" class=btn>         </p>     </form> 

and when button pressed. want run function in script.js file, example clear body.

what right way it?

many thanks!

add code in form tag onsubmit="javascript: function_name();" example:

<form name="name" id="name" onsubmit="javascript: function_name();">     // code </form> 

now in js, write:

<script> function function_name() {     alert("hi"); } </script> 

Comments

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -