Skip to content

Instantly share code, notes, and snippets.

@fleepgeek
Created January 30, 2019 11:08
Show Gist options
  • Save fleepgeek/c58dd7c28ae4574e601eb43dc2cb0090 to your computer and use it in GitHub Desktop.
Save fleepgeek/c58dd7c28ae4574e601eb43dc2cb0090 to your computer and use it in GitHub Desktop.
A simple JavaScript file to show basic DOM operations.
/*The DOM is a hierachy your browser creates for every webpage
<head> and <body> are on the same level (3rd level)
*/
// var body = document.getElementsByTagName('body');
// body[0].bgColor = 'blue';
// console.log(body);
// var container = document.querySelector('.container');
// container.innerHTML = '<h1>Hello</h1>';
// console.log(container);
// var main = document.getElementById('main');
// main.innerText = "Hello"
// main.style.height = '100px';
// main.style.backgroundColor = 'grey';
// console.log(main);
// var nameInput = document.getElementById('name');
// console.log(nameInput.hasAttribute('type'));
// console.log(nameInput.getAttribute('type'));
// nameInput.setAttribute('value', 'John');
// console.log(nameInput.getAttribute('value'));
// console.log(nameInput);
// container.classList.add('bg-green');
// container.className += " bg-green";
// var box = document.querySelector('.box');
// var btnShow = document.querySelector('.btn-show');
// btnShow.addEventListener('click', function() {
// box.classList.toggle('show');
// })
// document.addEventListener('DOMContentLoaded', function(){
// })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment