Welcome To Snipplr
Everyone's Recent JavaScript Snippets Tagged class
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
« Prev 1 Next »
Class member encapsulation in JavaScript is very important thing and may be implemented with easy. To define private property or method just use var before the definition or this., if you need to give a public access to property or method.
0
987
posted 10 years ago by apphp-snippets
This is a very basic wrapper for querySelectorAll. Just add prototypes and whatever else you need.
1
851
posted 11 years ago by o0110o
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
1344
posted 12 years ago by pmw57
Element.prototype functions to manipulate element classes.
1
781
posted 12 years ago by ChristianOttinger
"Javascript module pattern emulates the concept of classes in such a way that we're able to include both public/private methods and variables inside a single object, thus shielding/namespacing particular parts from the global scope."
When inheritanc...
0
926
posted 13 years ago by coprolit
Everything works as expected for the setTimeout() function until you try to call a method inside your ‘class’ (there are no real classes in JavaScript). Something like this won’t work:
setTimeout(this.methodToCall, time);
Passing a string r...
0
1204
posted 15 years ago by eden159
This is a simple javascript snippet that will allow you to specify a particular class to a group of checkboxes and then select them all at once when you click the master checkbox. This came in very handy for a store inventory script when I needed to...
0
1051
posted 16 years ago by aristoworks
One notorious discrepancy between IE and Firefox (or other "good" browsers) is the way they access the class HTML attribute. While I've used more complicated solutions in the past, this simple solution doesn't require any browser detection or even a...
2
995
posted 17 years ago by Todd
Based on the linked SitePoint article but with options to limit the container (eg body copy) and set the target. Use '_blank' for a new window for each link. Also adds a class (based on the rel value) for styling. Call the 'relWindow' on window load.
2
881
posted 17 years ago by mountainash
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
1136
posted 17 years ago by 1man
« Prev 1 Next »