This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| request = new XMLHttpRequest | |
| request.open('GET', '/my/url', true) | |
| request.send() | |
| request.onload = function() { | |
| data = JSON.parse(this.response) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| request = new XMLHttpRequest | |
| request.open('POST', '/my/url', true) | |
| request.send(data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| request = new XMLHttpRequest | |
| request.open('GET', '/my/url', true) | |
| request.send() | |
| request.onload = function() { | |
| resp = this.response | |
| } | |
| request.onerror = function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function fadeIn(el) { | |
| el.style.opacity = 0; | |
| var last = +new Date(); | |
| var tick = function() { | |
| el.style.opacity = +el.style.opacity + (new Date() - last) / 400; | |
| last = +new Date(); | |
| if (+el.style.opacity < 1) { | |
| (window.requestAnimationFrame && requestAnimationFrame(tick)) || setTimeout(tick, 16) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Show | |
| el.style.display = ''; | |
| // Hide | |
| el.style.display = 'none'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (el.classList) | |
| el.classList.add(className); | |
| else | |
| el.className += ' ' + className; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // After | |
| el.insertAdjacentHTML('afterend', htmlString); | |
| // Append | |
| parent.appendChild(el); | |
| // Before | |
| el.insertAdjacentHTML('beforebegin', htmlString); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Children | |
| el.children | |
| // Clone | |
| el.cloneNode(true); | |
| // Contains | |
| el !== child && el.contains(child); | |
| // Contains Selector |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var elements = document.querySelectorAll(selector); | |
| Array.prototype.forEach.call(elements, function(el, i){ | |
| }); | |
| el.innerHTML = ''; | |
| Array.prototype.filter.call(document.querySelectorAll(selector), filterFn); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Finding Children | |
| el.querySelectorAll(selector); | |
| // Finding Elements | |
| document.querySelectorAll('.my #awesome selector'); |
OlderNewer