Guest User

Untitled

a guest
Nov 23rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. Important DOM methods to get the document/doc_parts
  2.  
  3. var myVar = documnet.getElementsByClassName("content"); // returns an array of elements that has the class name "content"
  4. var myTag = myVar[1].getElementBsyTagName("h2"); // returns an array of elements that has the class name the tag name "h2"
  5. //can be done further operation with these returned objects, such as...
  6. myTag[0].innerHTML("what u want to change"); // should show the changes in the node/tag
  7. var myId = myTag[0].getElementById("page-title"); //NOT elements such above
  8.  
  9.  
  10. Important DOM properties and methods to change the document/doc_parts
  11. var content = document.getElementById("id");
  12. content.textContent; //gives the textcontents of the given id or
  13. content.textContent = "I should appear";
  14.  
  15. var link = content.getAttribute("href"); //"href" the attribute u want to call
  16. link.href // give the links that refers
  17.  
  18. content.setAttribute("href", "pi"); // replacing or adding new attributes
  19. title.style.left = 10px; // can be accessed to the css directly
  20.  
  21.  
  22. var name = document.createElement("name");
  23.  
  24. menu.appendNewChild(name);
  25. // can be added/removed(removeChild()) and so on
  26.  
  27. title.onclick = function(){};
Add Comment
Please, Sign In to add comment