Skip to content

Instantly share code, notes, and snippets.

@ijones922
ijones922 / windowload
Created June 4, 2014 15:26
window load
$(window).load(function() {
// executes when complete page is fully loaded, including all frames, objects and images
alert("window is loaded");
});
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6,
p, blockquote, pre, abbr, address, cite, code, del, dfn, em,
img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl,
dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption,
tbody, tfoot, thead, tr, th, td, article, aside, canvas, details,
figcaption, figure, footer, header, hgroup, menu, nav, section,
summary, time, mark, audio, video {
margin:0;
padding:0;
border:0;
@ijones922
ijones922 / gist:5952528
Created July 8, 2013 21:11
Javascript: document ready
$(document).ready(function(){
alert("success");
});
@ijones922
ijones922 / gist:5952576
Created July 8, 2013 21:17
Javascript: equal column heights
function matching_heights() {
var highestCol = Math.max($('').height(),$('').height());
$('').height(highestCol);
}
@ijones922
ijones922 / gist:5952705
Created July 8, 2013 21:35
Javascript: Preloading images
/**
* [ Preloading images is useful: Instead of loading an image when the user request it,
* we preload them in the background so they are ready to be displayed. Doing so in jQuery
* is very simple, as shown below:]
* Source: http://engineeredweb.com/blog/09/12/preloading-images-jquery-and-javascript
* @param {[type]} $
* @return {[type]}
*/
(function($) {
var cache = [];
@ijones922
ijones922 / gist:5952781
Created July 8, 2013 21:47
CSS: Debugging
/**
* Great little debuging snippet found while browsing
* The code adds different coloured borders to the assets depending on its level.
* Leave commented out if not needed.
*/
* { outline: 2px dotted red }
* * { outline: 2px dotted green }
* * * { outline: 2px dotted orange }
* * * * { outline: 2px dotted blue }
@ijones922
ijones922 / ellipsis
Created November 15, 2013 22:35
ellipsis
/* elipsify any text you want to truncate. Simply use .text(cut([n])) then .append() to add in any character(s) you want after. ex: ('...')*/
function cut(n) {
return function textCutter(i, text) {
var short = text.substr(0, n);
if (/^\S/.test(text.substr(n)))
return short.replace(/\s+\S*$/, "");
return short;
};
}