Recent Notes

Displaying keyword search results 1 - 10
Created by James on May 01, 2011 20:46:46    Last update: May 01, 2011 20:46:46
Unlike languages such as Python or PHP, an empty array in JavaScript is true . The proper way to test for an empty array is to check the length attribute: // empty array is true var anArray = []; if ...
Created by James on March 03, 2011 21:48:52    Last update: March 03, 2011 21:48:52
Just another way to left zero-pad a string. function zeroPad(s, length) { if (s.length ...
Created by James on October 11, 2010 19:01:28    Last update: January 11, 2011 20:38:56
Test page (click the "new window" icon to see the transition): <!DOCTYPE html> <html> <head> <title>jQu...
Created by James on October 11, 2010 18:14:41    Last update: January 11, 2011 20:36:01
Test page: <!DOCTYPE html> <html> <head> <title>jQu... Documentation: UI/Effects - jQuery JavaScript Library Effects - jQueryAPI
Created by James on May 24, 2009 20:14:25    Last update: January 11, 2011 20:07:38
In the following HTML code, I attached an inline handler to the text field input and added two event handlers with addEventListener / attachEvent . Both IE and Firefox called the inline handler first. But the order in which the added event handlers were called are different between IE and Firefox (IE calls attached_click2 first). Further, if I add the same event handler multiple times, IE calls the handler the same number of times. But Firefox only calls the same handler once, no matter how many times it was added. <html> <body> <form> Input: <input type="... You can attach an event handler to an HTML element either inline , with JavaScript , or by calling addEventListener (DOM level 2), or attachEvent (IE specific). When you...
Created by Dr. Xi on October 07, 2010 19:20:55    Last update: January 11, 2011 19:59:17
Like the string trim function, Firefox provides a native implementation for array map, IE doesn't. So we have to create our own map function for Array : if(typeof Array.prototype.map !== 'function') { ... Test page: <html> <head> <title>Array Map</...
Created by James on October 12, 2010 16:17:05    Last update: October 12, 2010 16:18:31
The splice method cuts elements from an array, and returns the cut-off elements as a new array. a = [1, 2, 3, 4, 5, 6, 7]; b = a.splice(1, ...
Created by James on October 12, 2010 15:48:29    Last update: October 12, 2010 15:48:29
The pop method removes an element from the end of an array; the shift method removes an element from the beginning of an array: a = [1, 2, 3, 4]; a.pop(); // 4 a.shift(); /...
Created by James on September 10, 2010 23:01:14    Last update: September 10, 2010 23:01:14
By default, heights for jQuery UI tab panels expand or contract depending on the height of each tab. The code snippet here sets the height of all tabs to be equal to that of the container. <!DOCTYPE html> <html> <head> <title>jQu...
Created by James on September 03, 2010 15:34:30    Last update: September 03, 2010 15:34:43
Combine the elements of a JavaScript array to a string by the join method: a = [ 'Eeny', 'meeny', 'miny', 'moe' ]; a.join(...
Previous  1 2 Next