Published: 2013-05-08 20:31:16
May 8, 2013 13:23||Refreshing my skills to Manipulate the HTML Document Model with Basic Javascript...
May 8, 2013 13:23||Refreshing my skills to Manipulate the HTML Document Model with Basic Javascript...
Your HTML5 based game will run inside a Web Page within the Browser. Where most of your efforts will be contained within a CANVAS Element, you have to know the basics about how to place that CANVAS within the confines of the Hosting Web Page.
document.getElementById("myList").appendChild(newListItem);
The appendChild() method appends a node as the last child of a node.
Tip: If you want create a new paragraph, with text, remember to create the text as a Text node wich you append to the paragraph, then append the paragraph to the document.
The <canvas> element is used to draw graphics, on the fly, on a web page.
The <canvas> element is only a container for graphics. You must use a script to actually draw the graphics.
Canvas has several methods for drawing paths, boxes, circles, characters, and adding images.
var element = document.createElement(tagName);
element - is the created element object.
tagName - is a string that specifies the type of element to be created. The nodeName of the created element is initialized with the value of tagName. Don't use qualified names (like "html:a") with this method.
If you want to quickly access the value of an HTML input give it an id to make your life a lot easier. This small script below will check to see if there is any text in the text field "myText". The argument that getElementById requires is the id of the HTML element you wish to utilize.
When using the getElementById function, you need to remember a few things to ensure that everything goes smoothly. You always need to remember that getElementById is a method (or function) of the document object. This means you can only access it by using document.getElementById.