Last active
August 18, 2016 04:34
-
-
Save altair21/86b331fee79e8d43069e0cbb29019a3b to your computer and use it in GitHub Desktop.
Revisions
-
altair21 revised this gist
Aug 18, 2016 . No changes.There are no files selected for viewing
-
altair21 created this gist
Aug 4, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ //add function to run after windown.onload function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ //JavaScript DOM only have insert one element before another function called "insertBefore", this for insert one after another function insertAfter(newElement, targetElement) { var parent = targetElement.parentNode; if (parent.lastChild === targetElement) { parent.appendChild(newElement); } else { parent.insertBefore(newElement, targetElement.nextSibling); } }