Wirting jQuery
1: //----------------------------------------------2: //a shortcut code noConflict3: (function($) {4: // do something on document ready5: })(jQuery);
7: //a long code8: $(document).ready(function() {9: // put all your jQuery goodness in here.10: });
12: //a shortcut code13: $(function() {14: // do something on document ready15: });
Fix error Conflict between many javascript library
//----------------------------------------------
//(noConflict) see reference site: http://api.jquery.com/jQuery.noConflict/
//Many JavaScript libraries use $ as a function or variable name,
//just as jQuery does. In jQuery's case, $ is just an alias for jQuery,
//so all functionality is available without using $.
//If we need to use another JavaScript library alongside jQuery,
// we can return control of $ back to the other library with a call to $.noConflict():$.noConflict();
//orjQuery.noConflict();
// Code that uses other library's $ can follow here.
Multiple $(document).ready() in one javascript file
$(document).ready(function() { // some code here }); $(document).ready(function() { // other code here });
Function define in one $(document).ready
block and call outside another $(document).ready
block
var demoFunction; $(document).ready(function() { // some code here demoFunction = function() { // some function that does stuff }; }); $(document).ready(function() { demoFunction(); });
continuous….
0 comments:
Post a Comment