Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 8th, 2013  |  syntax: HTML 5  |  size: 1.23 KB  |  hits: 28  |  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. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <script type="text/javascript" src="lib/http_code.jquery.com_jquery-1.9.1.js"></script>
  5.     <title></title>
  6. </head>
  7. <body>
  8. <script type="text/javascript">
  9.     $(document).ready(function ()
  10.     {
  11.         var $msgid = $("#msgid");
  12.         $msgid.html("This is Hello World by JQuery");
  13.         $("a").click(function ()
  14.         {
  15.             alert("Hello world!");
  16.         });
  17.  
  18.         var foo = [1, 2, 3, "sdf"];
  19.         $msgid.html(foo.length);
  20.  
  21.         // A function being attached to an object at runtime
  22.         var myName = "the global object";
  23.         var sayHello = function ()
  24.         {
  25.             var message = "Hi! My name is " + this.myName;
  26.             console.log(message);
  27.         };
  28.         var myObject = {
  29.             myName: "Rebecca"
  30.         };
  31.         var secondObject = {
  32.             myName: "Colin"
  33.         };
  34.  
  35.         myObject.sayHello = sayHello;
  36.         secondObject.sayHello = sayHello;
  37.  
  38.         sayHello();              // "Hi! My name is the global object"
  39.         myObject.sayHello();     // "Hi! My name is Rebecca"
  40.         secondObject.sayHello(); // "Hi! My name is Colin"
  41.  
  42.     });
  43. </script>
  44. <div id="msgid">
  45. </div>
  46. <a href="">Link</a>
  47. </body>
  48. </html>