Skip to content

Instantly share code, notes, and snippets.

View martinluz's full-sized avatar

Martin Luz martinluz

View GitHub Profile
// jQuery Masked Input
$('#celular').mask("(99) 9999-9999?9").ready(function(event) {
var target, phone, element;
target = (event.currentTarget) ? event.currentTarget : event.srcElement;
phone = target.value.replace(/\D/g, '');
element = $(target);
element.unmask();
if(phone.length > 10) {
element.mask("(99) 99999-999?9");
} else {
@martinluz
martinluz / gist:4529970
Created January 14, 2013 13:13
Javascript image preloader
//Source: http://stackoverflow.com/a/476681
function preload(arrayOfImages) {
$(arrayOfImages).each(function(){
$('<img/>')[0].src = this;
// Alternatively you could use:
// (new Image()).src = this;
});
}