1man


Member since 07/01/2006

Name: Matt Hobbs

Location: London

Website: http://nooshu.com

10 snippets

11072 profile views

0 Comment(s) Posted

View their favorites

Profile

Achievement

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

1man's Recent JavaScript SnippetsTagged function



« Prev 1 Next »
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 579 posted 16 years ago by 1man
Apologies if I haven't explained this to well, I'm still trying to get my head round closures.
0 564 posted 16 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 589 posted 16 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 669 posted 16 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 724 posted 16 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 666 posted 16 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 813 posted 17 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 937 posted 17 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 823 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 1830 posted 17 years ago by 1man
« Prev 1 Next »