<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script> </script> </head> <body> </body> </html>
In some cases, your webpage or the document on which you are working will not have a head section. Also in some case, for some reason, you will not have access to the head section. In some cases, by choice or constraints, you will not want to use/work on the head section. The second option you have is to include your script inside the body section section of the webpage. In this case, create the script section the same way as seen above. Here is an example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <body> <script> </script> </body> </html>
To display a comment on a line of text, start the line with two forward slashes //. Anything on the right side of // would be ignored. Here is an example:
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <script> // This line will be ignored. I can write in it anything I want. </script> </body> </html>
The above type of comment is used on only one line. You can also start a comment with /*. This type of comment ends with */. Anything between this combination of /* and */ would not be analyzed by the compiler. Therefore, you can use this technique to span a comment on more than one line.
While you can manually create comments, Microsoft Visual Studio provides a tool that can assist you. To add a comment on a line, click anything on that line. Then, on the Standard toolbar, click the Comment Out the Selected Lines button . To add comments to many adjacent lines, select the text on those lines and click the Comment Out the Selected Lines button . To remove the comments, click the line or select text on the lines. Then, on the Standard toolbar, click the Uncomment the Selected Lines button .
Introduction to HTML Events
An event is something that occurs to an object on a webpage. An example is that a user moves the mouse on a piece of text, clicks something on the screen, or types with the keyboard. The object on which the event occurs is said to fire the event.
HTML supports various type of events. Some events can be fired by any HTML tag and some events are made for some particular tags or some specific situations. Each event has a name.
One of the ways you use an event is to apply it to the desired tag in your webpage. The event is applied by adding its attribute to the tag. To specify what will happen when the object fires the event, you must assign something to the attribute. This would be done as follows:
<!DOCTYPE html> <html> <head> <title>Exercise</title> </head> <body> <form name="EmploymentApplication"> <p><input type="button" name="btnCreateName" value="Create Full Name" someEvent="" /></p> </form> </body> </html>
The Click Event
When a user clicks an object, such as a piece of text, a section of a web, or a button, the item fires an event named onclick. To use it, add it as attribute to the desired tag.
Practical Learning: Ending the Lesson
|Home||Copyright © 2001-2019, FunctionX||Next|