Being Awesome with Javascript and Jquery - PowerPoint PPT Presentation

raleigh
being awesome with javascript and jquery n.
Skip this Video
Loading SlideShow in 5 Seconds..
Being Awesome with Javascript and Jquery PowerPoint Presentation
Download Presentation
Being Awesome with Javascript and Jquery

play fullscreen
1 / 11
Download Presentation
Being Awesome with Javascript and Jquery
81 Views
Download Presentation

Being Awesome with Javascript and Jquery

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Being Awesome with Javascript and Jquery A tutorial by Zoe F

  2. <Html> <head> <script> I am some inline javascript </script> <script src=I am a link to an external javascript file.js> </head> <body> <a href = I am some built-in javascript>Text</a> </html

  3. Variables • Strings: • var a = "I am a string"; • var b = 'So am I!'; • Numbers: • var num1 = 100; • var num2 = 100.10; • var num3 = 0.10; • Booleans • var okay = true; • var fail = false; • Objects, arrays, functions

  4. Comparisions var foo = 1; var bar = 0; varbim = 2; foo == bar; // console would output false foo != bar; // true foo >bim; // false foo <= bim;//true

  5. Boolean Logic var foo = 1; var bar = 0; // returns 1, which is true foo || bar; // returns 0, which is false foo && bar;

  6. If/Thens if (thing you want to evaluate to true or false) { // The code in here will run. } else { // the code in here will run if the above is false. }

  7. An easier if/then statement: Switch switch ( foo ) { case "bar": alert( "the value was bar -- yay!" ); break; case "baz": alert( “It was baz:(" ); break; default: alert( “It wasnt either of those" ); }

  8. For loops for ( [initialization]; [conditional]; [iteration] ) { [loopBody] } for ( vari = 0; i < 5; i++ ) { // Logs "try 0", "try 1", ..., "try 4". console.log( "try " + i); }

  9. while ( [conditional] ) { [loopBody] } vari = -1; while ( ++i < 100 ) { //this is the same as writing “while ((i=i+1)<100)” // This block will be executed 100 times. console.log( "Currently at " + i ); }

  10. Functions Function buyOranges() { Find some oranges Bring them to me }; Function buyOranges(amount, maxCost) { Find some oranges Choose amountof them If they are less than maxCost, bring them to me }; buyOranges(5, 20); //Buy me 5 oranges if it’s less than $20

  11. Jquery:It’s just another bunch of functions Reference: http://www.w3schools.com/jquery/default.asp