function askName() { /* Example of multiline comment- Experience of Javascript! I hope you may like it.*/ alert("Welcome to My First JavaScript"); //single line comment - display your message, a kind of output to users. var userinput=prompt("Enter your name and Click OK", "Enter your name here! "); //this is a kind of input var welcome_message="Welcome " + userinput+ "!"; //processing userinput alert(welcome_message); //display processed userinput. } function useTextbox() { var userName= document.getElementById("inputName").value; document.getElementById("outputName").value = userName; }
JavaScript can react to events. Like the click of a button:
Put your name:
Your Name is
innerHTML