Welcome To Snipplr


Everyone's Recent JavaScript Snippets Tagged DOM



1 2 Next »
This function will sort an array of DOM elements in order of the DOM position. Useful when using calls such as $$("img.L,img.M") which doesn;t return a sorted element array. It uses prototype but you can replace the Prototype.Browser stuff with a...
0 861 posted 15 years ago by kouphax
Borrowed from Ajaxian, url is above.
0 607 posted 15 years ago by mikegreen
Use sample: var inputTxt = getElementsByAttr('input', 'type', 'text');
1 527 posted 15 years ago by kcmr
Determines if a given element is visible, by checking a variety of things. Will work for CSS or inline style declarations of visible:hidden or display: none. Will check if it's inside of an invisible element, as well.
3 807 posted 15 years ago by TALlama
This is a little trick I came up with to add outerHTML functionality in Firefox. For those who aren't familiar with outerHTML, it is an IE addition to the DOM that will return the element's HTML PLUS it's innerHTML. Is it really needed? No, but it ca...
1 1239 posted 16 years ago by localhorst
This script can help you control the scroll of div by a simple function. Set thr property 'scrollTop' then the scoll can be controlled.
1 1033 posted 16 years ago by multani
Oh so sweet. A big thanks to Chris Poole for this one.
1 445 posted 16 years ago by Hanek
var lib = ['foo.js','foo.js','foo2.js','foo.js','foo333.js','foo2.js']; var slib = 'fooooo.js'; lib.jitScript(); // append foo.js, foo2.js & foo33.js slib.jitScript(); // append fooooo.js enable firebug console JitScriptDebug = true; val...
0 647 posted 16 years ago by ChaosKaizer
0 3680 posted 16 years ago by elugardo
Simply replaces the div's innerHTML with the response text received from the file.
3 1301 posted 17 years ago by 1man
This while loop will remove all childNodes from a selected element.
1 521 posted 17 years ago by 1man
This function allows you to open a new window, without using any inline Javascript. Simply add rel="external" to the link you wish to open in a new window.
3 936 posted 17 years ago by 1man
Use this function to queue functions you wish to load on window onload. Very useful when code becomes complex.
3 916 posted 17 years ago by 1man
Usage of the getNextElement function. Very basic usage to pick out the h1 tags, then change the properties of the next element(not node).
1 665 posted 17 years ago by 1man
Useful function for CSS DOM, returns the next element after the selected node. So you could style the element directly after a h1 element for example.
2 590 posted 17 years ago by 1man
This is another script from the DOM scripting book. Not really relevant to anybody else. Useful for reminding myself about the DOM.
1 615 posted 17 years ago by 1man
Not really relevant to anybody else. Full unobtrusive js file for a simple gallery. From DOM Scripting by Jeremy Keith (superb book, highly recommend it for anyone looking to move into DOM scripting)
2 556 posted 17 years ago by 1man
Vert useful function since there isn't an insertAfter function in the DOM. Call it inside scripts, it expects insertAfter(*the new element to be inserted*, *the element you want it to be inserted after*);
3 1779 posted 17 years ago by 1man
Source: Browser inspecific referencing @ howtocreate
1 542 posted 17 years ago by mlange
3 640 posted 17 years ago by mlange
Constructs an element out of arrays. Using nested arrays translates into nested ChildNodes. Update 2006-07-19: Added documentation (comments). Update 2006-11-25: Reduced the ammount of code needed.
5 719 posted 17 years ago by rolandog
For a working demo in application/xhtml+xml or text/html, go to: http://rolandog.com/archives/2006/07/10/litebox-demasiado-bueno-para-ser-cierto/ You should delete the multi-line comments after completing the setup, some old browsers will complai...
3 922 posted 17 years ago by rolandog
This script makes it possible to delete every childNodes, childNodes.childNodes, childNodes.childNodes.childNodes and so on. Includes example functions for deleting all childNodes, firstChild and lastChild from an 'id'. It uses twin functions that ca...
0 611 posted 17 years ago by rolandog
1 2 Next »