Java Reference
In-Depth Information
docNavigate.appendChild(textNodeA1); //Adds the second text node
docNavigate = docNavigate.nextSibling; //Moves to the next TD element
docNavigate.appendChild(textNodeA2); //Adds the second text node
docNavigate = docNavigate.nextSibling; //Moves to the next TD element
docNavigate.appendChild(textNodeA3); //Adds the third text node
docNavigate = docNavigate.parentNode; //Moves back to the TR element
docNavigate = docNavigate.parentNode; //Moves back to the table element
docNavigate.appendChild(trElem2); //Adds the second TR element
docNavigate = docNavigate.lastChild; //Moves to the second TR element
docNavigate.appendChild(tdElem4); //Adds the TD element
docNavigate.appendChild(tdElem5); //Adds the TD element
docNavigate.appendChild(tdElem6); //Adds the TD element
docNavigate = docNavigate.firstChild; //Moves to the first TD element
docNavigate.appendChild(textNodeB1); //Adds the first text node
docNavigate = docNavigate.nextSibling; //Moves to the next TD element
docNavigate.appendChild(textNodeB2); //Adds the second text node
docNavigate = docNavigate.nextSibling; //Moves to the next TD element
docNavigate.appendChild(textNodeB3); //Adds the third text node
docNavigate = docNavigate.parentNode; //Moves back to the TR element
docNavigate = docNavigate.parentNode; //Moves back to the table element
docNavigate.appendChild(trElem3); //Adds the TR element
docNavigate = docNavigate.lastChild; //Moves to the TR element
docNavigate.appendChild(tdElem7); //Adds the TD element
docNavigate.appendChild(tdElem8); //Adds the TD element
docNavigate.appendChild(tdElem9); //Adds the TD element
docNavigate = docNavigate.firstChild; //Moves to the TD element
docNavigate.appendChild(textNodeC1); //Adds the first text node
docNavigate = docNavigate.nextSibling; //Moves to the next TD element
docNavigate.appendChild(textNodeC2); //Adds the second text node
docNavigate = docNavigate.nextSibling; //Moves to the next TD element
docNavigate.appendChild(textNodeC3); //Adds the third text node
</script>
</body>
</html>
Save this as ch9 _ question1.html .
exercise 2 Question
Modify Example 6 so that the amount of pixels moved in either direction is controlled by a global
variable. Call it direction . Remove the switchDirection variable, and change the code to use the
new direction variable to determine when the animation should change directions.
exercise 2 Solution
<!DOCTYPE html>
<html lang="en">
<head>
<title>Chapter 9, Question 2</title>
Search WWH ::




Custom Search