HTML and CSS functions

s

JavaScript Functions:

These are the two methods of Javascript that I know so far

  • confirm("")
    • Inside goes the text that will pop up in the confirm window
  • alert("")
    • Inside goes the text that will pop up in the alert
  • console.log("")
    • This is to print stuff to the console
  • document.write("")
    • This is to write something to the page itself
      • Theres really no reason to use this, because it is easier to just use HTML to wite something to the page.
    • If you call this in a function during the usage of the page (like in a button)
      • Then it will fuck up
    • Basically don't use this
  • .getElementsByClassName("")
    • If you print this to the console, then it will just print a bunch of useless shit about the class
  • .getElementById("")
    • If you print this to the console then it will give you the entire code of the element whose id you gave.
  • Javascript can be used to change HTML attribute values or CSS styling

  • document.getElementById("").innerHTML
    • This is print everything between the tags of the specified element
    • It will return a string
    • document.getElementById("").innerHTML = "this is a string";
      • You can change a string with this method, and since when you write something as a string in an editor...you can change HTML code
      • UPDATE: nvm, the follow code actually worked....
  • Here I tried to use innerHTML to show the button tag, but it showed an actual button instead
    • I couldnt get this to work manually, but it worked in this case......by mistake.
  • You can also use document.getElementById("").innerHTML to change code with the specied element
    • if the element is a div

  • document.getElementById("").href
    • You can do this: document.getElementById("").href = "https://www.w3schools.com";
      • This changes the link of something
  • document.getElementById("").target
    • You can do this: document.getElementById("").target = "_blank"
      • The target attrbite specifies where to open the linked document
  • document.getElementById("").src
    • You can do this: document.getElementById("").src = "pic_bulbon.gif"
      • The src attribute species with image to open. This attribute is only used with images / videos. Links use href

  • document.getElementById("").style
    • you are able to change CSS styling because of inline-styles in HTML
    • Ex: document.getElementById("").style.fontSize = "35px";
    • var numOne = document.getElementById(“num-one”);
      • Here you are storing the num-one element in the variable "numOne"

    • numOne.addEventListener(“click”, funct_to_be_executed());

    • var node = document.createElement("p");
    • document.body.appendChild(node);

    Home

    Fonts

    Units

    Javascript

    HTML Attributes

    HTML tags

    Ruby