Created
January 21, 2011 05:59
-
-
Save zaius/789302 to your computer and use it in GitHub Desktop.
Overriding of console for debugging on jquery plugins
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
<html> | |
<head> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
$(function() { | |
$.fn.myWidget = function(params) { | |
(function(console){ | |
if (!params.debug) console = { log: function(){} }; | |
console.log("Logging enabled!"); | |
})(console); | |
}; | |
$('#mydiv2').myWidget({debug: false}); | |
$('#mydiv1').myWidget({debug: true}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="mydiv1">div one</div> | |
<div id="mydiv1">div two</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment