Dom.txt

    • author "me"
    • fileName "Dom"
    • tags ""
    • description ""
    • Dom is ______
    • Document Object Model
  1. Dom Methods
    getElementById(" ")

    getElementsByTagName(" CAP ")
  2. First,
    Get a handle
  3. Step 1
    Example
    var myPtag = document.getElementById("P1");
  4. Step 2
    You can do anything u want after u have a handle
  5. Examples of step 2,
    Changing text
    myPtag.innerHTML = "new text"
  6. Examples of step 2
    Assigning CSS class using className property
    myPtag.classname = "newCssClass";
  7. Examples of step 2
    Changing online style (ie text color) using the style property
    myPtag.style.color = "#900";
  8. Using method getElementsByTagName
    Is more specific than getElementById
  9. getElementById is _____ than getElementsByTagName, so usually ______
    • Broader
    • Use get ElementById first
  10. Example of using the getElementsByTagName method
    var container, myLItags;

    • container = document.getElementById("exams");
    • // remember use caps when identifying tag names
    • myLItags = container.getElementsByTagName("LI");
  11. Once, you get from getElementsByTagName, it comes in as
    Array
  12. You can use array notification to specify
    myLItags[1].style.backgroundColor = "#fff";

    You can also use loops to access elements
  13. Loop to access all the elements
    • for (var n = 0, len = myLItags.length, n<0, n++) {
    • if (myLITags [n].innerHTML === "100") {
    • myLITags[ ].style.font = "120%")
    • }
    • }
Author
kimo
ID
165880
Card Set
Dom.txt
Description
Javascript Dom
Updated