Skip to content

Instantly share code, notes, and snippets.

@codenart
codenart / null.js
Last active July 13, 2018 08:02
Using for tutorials on codenart.github.io
var box = null;
console.log(box);
// result: null
@codenart
codenart / undefined.js
Created July 13, 2018 08:01
Using for tutorials on codenart.github.io
var box;
console.log(box);
// result: undefined
@codenart
codenart / dropdown.js
Last active July 5, 2018 04:44
Using for tutorials on codenart.github.io
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Actions
*/
function showList(event) {
var theList = document.getElementById('the-list');
theList.className = 'dropdown-list showing';
}
function hideList(event) {
@codenart
codenart / dropdown.js
Last active July 1, 2018 07:58
Using for tutorials on codenart.github.io
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Actions
*/
function showList(event) {
var theList = document.getElementById('the-list');
theList.className = 'dropdown-list shown';
}
function hideList(event) {
@codenart
codenart / dropdown.js
Last active June 27, 2018 13:25
Using for tutorials on codenart.github.io
var theList = document.getElementById('the-list');
console.log( theList.className );
// 'dropdown-list shown'
theList.className = 'dropdown-list hidden';
// hiding the list
@codenart
codenart / dropdown.js
Last active June 28, 2018 08:36
Using for tutorials on codenart.github.io
var theList = document.getElementById('the-list');
var firstItem = theList.firstElementChild;
console.log( firstItem.textContent );
// 'The rose is red'
firstItem.textContent = 'The flower is dancing';
// changing content
@codenart
codenart / dropdown.js
Last active June 27, 2018 09:28
Using for tutorials on codenart.github.io
var theList = document.getElementById('the-list');
console.log(theList);
// the dropdown list element
@codenart
codenart / dropdown.js
Last active June 29, 2018 13:23
Using for tutorials on codenart.github.io
var body = document.body;
// start traveling from <body>
var html = body.parentElement;
// its parent is <html>
var head = body.previousSiblingElement;
// its previous sibling is <head>
var dropdown = body.firstElementChild;
@codenart
codenart / dropdown.js
Last active June 27, 2018 08:31
Using for tutorials on codenart.github.io
var head = document.head;
console.log(head);
// an object models the element <head>
var body = document.body;
console.log(body);
// an object models the element <body>
@codenart
codenart / dropdown.css
Last active June 26, 2018 03:59
Using for tutorials on codenart.github.io
.dropdown {
font-family: Arial, sans-serif;
font-size: 16px;
display: inline-block;
position: relative;
}
.dropdown-btn {
font-size: 14px;