HTML and CSS Reference
In-Depth Information
The function addBlog() is a user-defined function, not part of the class. Its func-
tion is to create a new blog object and assign it properties.
The form data (the blogger's name and blog message) is retrieved with the
document.getElementById() method.
An instance of a new BlogEntry object is created and a reference to it is assigned
to the variable, blog . The methods for the object are called to set the properties for
the blog object.
After setting up all the weather images, this is the div container where the blog
messages will be stored and displayed.
The user will write his or her blog in a textarea input device. After writing the mes-
sage, if the user leaves the text area and then clicks in the box, the onfocus event
handler will be triggered and the box will be cleared by setting its value to an emp-
ty string.
When the user clicks this button, the onclick event hander will call the addBlog()
function to create a new blog object and set its properties with the form data re-
trieved on line 17. The results are shown in Figures 15.18 and 15.19.
Figure 15.18 Before adding a blog entry.
Search WWH ::

Custom Search