Last active
October 28, 2015 20:34
-
-
Save schnogz/9df8b8a304be233a7671 to your computer and use it in GitHub Desktop.
monkey patching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a closure and remap jQuery to $ | |
(function($){ | |
// save off original method | |
var _originalAppendTo = $.fn.appendTo; | |
// override method | |
$.fn.appendTo = function() { | |
// silly code to alternate backgound color | |
if ($(document.body).children().length % 2) { | |
document.body.style.background = "#f285cf"; | |
} else { | |
document.body.style.background = "#85C3F2"; | |
} | |
// call original passing in scope and arguments | |
return _originalAppendTo.apply(this, arguments); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment