Adding JavaScript Code
Learn how to add Javascript to build the functionality of the HTML form.
We'll cover the following...
We'll cover the following...
When you create an HTML form, pressing a button submits the form by default. Submitting a form reloads the page. Once you reload the page, the data entered in the textfield is lost. This is what we will prevent now.
First, we created a helloListener
function in JavaScript. This function prevents the default action of the event, which is the submission of the form.
The second line in the function creates a console log that appears in the developer tools of your browser. More ...