Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 3rd, 2012  |  syntax: None  |  size: 0.91 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. what's the meaning of the way of writing in jquery?
  2. $.each(obj,function(key,value) {})
  3.        
  4. $('document').ready(function(){}); or     $(function(){});
  5.        
  6. function myFunction() {
  7.    alert("This is myFunction");
  8. }
  9.  
  10. myFunction();      // alerts "This is myFunction"
  11.        
  12. myFunction.someProperty = "test";
  13. alert(myFunction.someProperty);    // alerts "test"
  14.        
  15. myFunction.someMethod = function() {
  16.                           alert("This is someMethod");
  17.                         };
  18.  
  19. myFunction.someMethod();    // alerts "This is someMethod"
  20.        
  21. $(function(){});
  22. // is equivalent to my example
  23. myFunction();
  24.  
  25. $.each();
  26. // is equivalent to my example
  27. myFunction.someMethod();
  28.        
  29. $(document)
  30. // returns a jQuery object that has a "ready" method so you can say
  31. $(document).ready();
  32. // which is equivalent to
  33. var doc = $(document);
  34. doc.ready();
  35.        
  36. $('div').hide().fadeIn().fadeOut().show();
  37.        
  38. $('a')
  39.        
  40. $.each(...)
  41.        
  42. $('a').hide();