Skip to content

Instantly share code, notes, and snippets.

var createPerson = function(name) {
var _name = name;
return {
getName: function() {
return _name;
}
};
};
(function(module, undefined) {
// Anything declared at this level is only accessible within this
// function. Efectively, they will be the module's private variables.
var _answer = 42;
// The module's public interface is then defined by declaring variables on
// the module variable that was passed in.
module.getAnswer = function(question) {
(function(m) {
m.doStuff = function() {
// TODO: Stuff
};
})(window.deeply.nested.module);
window.deeply.nested.module.doStuff();
(function($) {
$.fn.enable = function() {
// Enable each selected element by removing its 'disabled' attribute.
return this.each(function() {
$(this).removeAttr('disabled');
});
};
$.fn.disable = function() {
$.fn.disable = function() {
return this.filter(':input').each(function() {
$(this).attr('disabled', 'disabled');
});
};
<head>
<link rel="stylesheet" href="base.css" />
<link rel="stylesheet" href="mobile.css" media="max-width: 320px" />
<!-- OR -->
<style type="text/css">
/* base styles go here */
@media (max-width: 320px)
<!-- Common styles -->
<link rel="stylesheet" href="base.css" />
<!-- For tiny (most likely mobile) browsers -->
<link rel="stylesheet" href="small.css" media="max-width: 320px" />
<!-- For small desktop or large mobile browsers -->
<link rel="stylesheet" href="medium.css"
media="min-width: 321px and max-width: 799px" />
<meta name="viewport" content="width=device-width" />
#wrapper
{
-webkit-transition: width 0.2s ease-in-out;
-moz-transition: width 0.2s ease-in-out;
-o-transition: width 0.2s ease-in-out;
transition: width 0.2s ease-in-out;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Templates Yay</title>
</head>
<body>
<div id="music"></div>
<script id="musicTemplate" type="text/x-jquery-tmpl">