Welcome To Snipplr
Everyone's Recent JavaScript Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
JavaScript
Template for a Javascript function with optional and mandatory arguments passed as an object collection
A simple template for a JavaScript function which allows for an arbitrary number of named arguments to be passed in. This is achieved by passing a single object as an argument with each of the 'real' arguments being a key/value pair. In this way argu...
0
1356
posted 11 years ago by davidwaterston
Logs offline application cache states. Swaps cache if updated version is available.
0
663
posted 11 years ago by zfisic
Basic information on JavaScript from CodeAcademy.com's JavaScript track
0
779
posted 11 years ago by denakitan
JavaScript is the only option, if you want to have the ability to clear all form fields. Yes, HTML form has Reset method, but if the form has initial values, then Reset will return the form to the initial state instead of clear input fields. This exa...
1
934
posted 11 years ago by laxman2021
For those moments of weakness when .replace() looks like a good idea...
0
994
posted 11 years ago by inreflection7
Ask the user with a confirmation dialog if the link should be followed or not.
0
685
posted 12 years ago by gummiost
The marquee will stop when you hover the cursor over it. It will restart when you move the cursor away from it.
1
890
posted 12 years ago by o0110o
**Simple JavaScript Quiz**
Edit the main quiz array with your own questions, then publish. Since it's an entire HTML file, it's best to save this file on a server and embed it as needed using an iframe tag.
0
2543
posted 12 years ago by jrue
Set the desired date within the function.
Make some images and label them "1.jpg, 2.jpg, 3.jpg, etc...".
That's how it's done.
1
915
posted 12 years ago by o0110o
Any valid json object will be recursively traversed building a nested unordered list of its properties and their values. This example parses the json entered in the text area into an object that is passed to the json_tree() function. I use the twit...
0
1104
posted 12 years ago by halk
Emulates the StringBuilder() function found in .NET Languages
0
614
posted 12 years ago by jswaringen
this is how to instantiate a dropdown shadow using js code, works in IE10 and windows store apps. Important for when you want use templates.
0
1256
posted 12 years ago by Syllogism
Para limpiar o borrar una parte especifica de nuestro canvas podemos usar la función clearRect()
0
1409
posted 12 years ago by maiden
Allows you to click a given checkbox X, then shift click another checkbox Y. All checkboxes between X and Y will be checked or unchecked based on the state of checkbox Y. i.e. if you're unchecking Y all boxes between X and Y will also be unchecked.
1
1305
posted 12 years ago by ReedD19
Simple code example that allows you to pull a time stamp / timestamp to attach to end of URL for GET POST calls
0
1077
posted 12 years ago by kutyadog
Code from https://snipt.net/geekyjohn/get-url-param/ updated so that most jslint issues are resolved, and updated the return to use a guard condition instead of a separate if statement.
1
1220
posted 12 years ago by pmw57
Standard hasClass, addClass, and removeClass functions.
- reworked so that jsLint is happy about them
- removeClass function trims things after removing a class name
- tests help to ensure that all common use-cases are covered
2
1347
posted 12 years ago by pmw57
Simulate the $_GET array from php in javascript to get url parameters this way:
url= http://localhost/?var1=example
$_GET['var1'] will return "example"
Just copy and paste the code.
2
1122
posted 12 years ago by sergiazow
Comprueba la existencia de una cadena de texto en un input con javascript. (LA impresion del input está en CAKEPHP)
0
743
posted 12 years ago by serialk89
Simply changes the name attribute on input elements when the page is loaded.
0
798
posted 12 years ago by stevielamb83
How does it work?
This code checks/unchecks all checkboxes within the same fieldset. Simple and semantic.
HTML Setup
Add checkboxes however you like, just make sure they are within the same fieldset.
<fieldset>
<!-->
<div><input>...
1
732
posted 12 years ago by dnnsldr
Here’s a handy bit of code that I use quite regularly, its particularly useful if your getting a response message from a form to notify the user that there data was sent, or comunicate an error and you want to fade the message out after a set time.
1
922
posted 12 years ago by dnnsldr
//You cannot change the whole url without redirecting, what you can do instead is change the hash.
//The hash is the part of the url that goes after the # symbol.
//That was initially intended to direct you (locally) to sections of your HTML doc...
0
908
posted 12 years ago by dnnsldr