mrspoonzy at gmail Cube by Noah Ellman A powerful javascript toolkit, in research © by Noah Ellman

Misc Coding Examples

Here are various coding examples of how to acheive some common and perhaps not common tasks. Hopefully these examples will help you become familiar with jWarp's style of coding.

Example of using Jwee's special Function methods.

Say you have an HTML element with id='mydiv'.


Easily permanently pass a value to a function, such as shake(), using passing(..). Since passing is also a function, you can then call the later(xx) method to cause the function execute after a certain millasecond delay. COOL!

How would you hide all the images inside an element called #myGallery ?

$('#myGallery img') ).each( ".hide()" );

  1. retreives the array of images
  2. $ ensures that all the img elements in the array are "extended"
  3. The each function is a special function that arrays have.
  4. each normally takes a function, but it can also take a string like the example above. If this string represents a function call, then each will execute this function on all elements in the array.

How would I code the icon rollover animations like the tabs have on the top of this site. ?

Event.onReady(function() {'#navlinks a').each( function(item) {
			var img = item.query('img')[0];
			item.onmouseover = function() { 
			item.onmouseout = function() {


The fun code below selects more or less all the html elements on the page with, then iterates through them with .each via the function passed to .each. The each callback takes the elements one by one, calls the .animate magic method and fades the alpha or opacity of the element to 0, hiding it. The addition of .callLater, which is a magic method extented on all functions, automatically delays the execution of the .animate by a specificied number of millasecond, which in the case below is index*100.'a, span, p, b, i, em, strong, li,, code, pre,, div, h1, h2, h3, h4').each( 

	function(ele,index) { 


Discussion on /coding-examples-misc