Understanding Objects
value Example: txtFirstName. The dot notation is the key that opens the door to the house. Properties room Methods room Events room id value size background color… focus() blur() - remove focus select()… OnFocus OnBlur - loses focus OnChang e OnClick … Top down View Example: A TextBox Object …with 3 rooms An Object is like a house…
Remember: The dot (a period) gives you access to all the properties, all the methods, and all the events inside the object.
Also Remember: You must use JavaScript’s getElementById() function to GET the object first.
If you don’t use getElementById(), you can’t even SEE the house! It doesn’t even exist for you.
A Code Example // declare a variable to hold the textbox object var txtFirstName; // grab the object using getElemtnById() and assign it to the variable txtFirstName = document.getElementById(“txtFirstName”); // display the value (the actual text) of the textbox alert(txtFirstName.value); Notice the dot – the key that opens the door to the object!
Thanks for watching.