first submission:submitting first snipplet popular snippet:having a snipplet with 20 favorites

1man's Recent SnippetsTagged function

« Prev 1 Next »
A way to time how long it takes to get through a certain block of code. Good way to measure performance on the page. You could also use the built in logging functions in firebug. Not sure how they would tally up in a test.
1 138 posted 11 years ago by 1man
Quick example to show how 'this' depends on how the function in which you called it in was being invoked. From jQuery in Action.
1 95 posted 12 years ago by 1man
Apologies if I haven't explained this to well, I'm still trying to get my head round closures.
0 83 posted 12 years ago by 1man
This method allows you to call a function as a method of another object. The first argument the call method expects is the object it is to operate on. Any others are part of the function. Note how the this keyword now refers to the comp object, so a...
0 88 posted 12 years ago by 1man
The important thing to notice is the () operator in a[2]. It is invoking the function inside a[0] with the argument a[1].
1 125 posted 12 years ago by 1man
Every function has an object called the arguments object. This is an object that contains all the arguments that were passed to the function. The example below shows how to access these. Very rarely used but useful to know. Note: it may look like an...
2 108 posted 12 years ago by 1man
Simple way of allowing functions to take optional arguments. Always place the optional arguments last, so you don't have to explicitly pass an argument as "undefined".
3 109 posted 12 years ago by 1man
Very basic grab a line of text from a file then display it in an alert box. Uses other functions for loading prepareLinks() and creating the request.
2 130 posted 13 years ago by 1man
Function to look if an element has a class, if it doesn't simply add it to the element. If it does have a class add it to the class that is already there. Function expects 2 values, the element to add the class to, and the new class name (value).
3 157 posted 13 years ago by 1man
This function looks for tables in a web page, then loops through the rows and sets the backgroundColor for ever other row.This creates a striped table which is easier to read.
2 135 posted 13 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 517 posted 13 years ago by 1man
« Prev 1 Next »