Skip to content

Instantly share code, notes, and snippets.

View javascript native currency format
const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2
})
formatter.format(1000) // "$1,000.00"
formatter.format(10) // "$10.00"
formatter.format(123233000) // "$123,233,000.00"
View HEAD.JS Docs
LOADING
//////////////////////////////////////////////////////////////////////////////////
// queue scripts and fire a callback when loading is finished
head.load("file1.js", "file2.js", function() {
// do something
});
// same as above, but pass files in as an Array
head.load(["file1.js", "file2.js"], function() {
// do something
@ArtGiven
ArtGiven / s
Created May 27, 2019
universalLoading("class", "id");
View s
universalLoading("class", "id");
View jQuery JS replacements
javascript shorthand list: https://www.sitepoint.com/shorthand-javascript-techniques/
SCE function to get and check element // will avoid "of unexpected.." error:
let a = x0(".MobileSearchWrapperHelper");
a ? a.style.display = "block" : void 0;
$(element).is(':visible')
element.offsetWidth > 0 && element.offsetHeight > 0;
window on load:
@ArtGiven
ArtGiven / s
Created Jan 9, 2019
onclick="toggleActive(this, '0', true, false)" on any element a = this b = select parent '0' takes this element '-1' selects first parent, '-2' selects second parent, etc. c = true|false remove/hide this element when clicked outside (great for toolt
View s
onclick="toggleActive(this, '0', true, false)" on any element
a = this
b = select parent '0' takes this element '-1' selects first parent, '-2' selects second parent, etc.
c = true|false remove/hide this element when clicked outside (great for tooltips, popups, etc)
d = run custom function after opening, example: myfunction()
@ArtGiven
ArtGiven / Custom Checkbox and Radio Buttons.html
Created May 17, 2017
Custom Checkbox and Radio Buttons
View Custom Checkbox and Radio Buttons.html
example: https://bootsnipp.com/snippets/ZkMKE
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css">
<div class="container">
<h2>Checkboxes</h2>
<form role="form">
<div class="row">
<div class="col-md-4">
<fieldset>
View label JS events.js
$(window).bind("resize.rainbows", function(e){
// do something when any span.rainbows element resizes
});
$(window).unbind("resize.rainbows");
View SCECSS3-Animations.html
https://github.com/daneden/animate.css
Add the class "animated" to the element you want to animate. You may also want to include the class infinite for an infinite loop.
Finally you need to add one of the following classes:
Class Name
bounce flash pulse rubberBand
@ArtGiven
ArtGiven / Add URL query
Last active Dec 12, 2016
Add URL query
View Add URL query
UpdateQueryString(key, value, url, redirect)
url is not needed as it will generate automatically unless you want a different one
redirect = true or false