SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
JavaScript



Tuesday, April 16, 13
The Script Tag

                   <script>
                       alert("My First JavaScript");
                   </script>




Tuesday, April 16, 13
JavaScript Language



Tuesday, April 16, 13
JavaScript Statements
      JavaScript statements are "commands" to the browser. The purpose
      of the statements is to tell the browser what to do.




    <script>
       document.getElementById("demo").innerHTML="Hello";
    </script>




Tuesday, April 16, 13
Semicolon ;
     Semicolon separates JavaScript statements.
     You add a semicolon at the end of each executable statement.




    <script>
       document.getElementById("demo").innerHTML="Hello";
    </script>




Tuesday, April 16, 13
JavaScript Code
      JavaScript code (or just JavaScript) is a sequence of JavaScript
      statements. Each statement is executed by the browser in the
      sequence they are written.



    <script>
       document.getElementById("demo").innerHTML="Hello";
       document.getElementById("myDIV").innerHTML="Hi";
    </script>




Tuesday, April 16, 13
JavaScript Functions
      The purpose of a function is to make the sequence of statements
      execute together when called



    <script>
       function myFunction() {
          document.getElementById("demo").innerHTML="Hello";
          document.getElementById("myDIV").innerHTML="Hi";
       }
    </script>




Tuesday, April 16, 13
JavaScript is Case Sensitive
      Watch your capitalization closely when you write JavaScript
      statements:
      A function getElementById is not the same as getElementbyID.



    <script>
       function myFunction() {
          document.getElementById("demo").innerHTML="Hello";
          document.getElementbyId("demo").innerHTML="Hello";
       }
    </script>



Tuesday, April 16, 13
JavaScript Comments
      Comments will not be executed by JavaScript.
      Comments can be added to explain the JavaScript, or to make the
      code more readable.
      Single line comments start with //.

    <script>
       function myFunction() {
          // Write to a heading
          document.getElementById("demo").innerHTML="Hello";
       }
    </script>



Tuesday, April 16, 13
JavaScript Comments
      In the following example the comment is used to prevent the
      execution of one of the codelines (can be suitable for debugging):




    <script>
       function myFunction() {
          // document.getElementById("demo").innerHTML="Hello";
       }
    </script>




Tuesday, April 16, 13
JavaScript Functions w/Arguments
      When you call a function, you can pass along some values to it, these values
      are called arguments or parameters.

      These arguments can be used inside the function.

      You can send as many arguments as you like, separated by commas (,)


    <script>
       function myFunction(parameter1, parameter2) {
          document.getElementById("demo").innerHTML= parameter1;
          document.getElementById("myDIV").innerHTML= parameter2;
       }
    </script>


Tuesday, April 16, 13
jQuery
                        docs.jquery.com


Tuesday, April 16, 13
jQuery
      jQuery commands with a call to the jQuery function. Here is how a jQuery
      statement is constructed.




                        jQuery(‘p’).css(‘color’, ‘blue’);

         selector                   action               parameters
    jQuery(‘p’)                      .css            (‘color’, ‘blue’)




Tuesday, April 16, 13
jQuery selectors
      Same as CSS. Tags, Classes and IDs




      jQuery(‘p’).css(‘color’, ‘blue’);
      jQuery(‘.classname’).css(‘color’, ‘blue’);
      jQuery(‘#idname’).css(‘color’, ‘blue’);




Tuesday, April 16, 13

Weitere ähnliche Inhalte

Was ist angesagt? (11)

Introduction to thymeleaf
Introduction to thymeleafIntroduction to thymeleaf
Introduction to thymeleaf
 
Java script errors &amp; exceptions handling
Java script  errors &amp; exceptions handlingJava script  errors &amp; exceptions handling
Java script errors &amp; exceptions handling
 
Programming style
Programming styleProgramming style
Programming style
 
jQuery basics
jQuery basicsjQuery basics
jQuery basics
 
Java Script
Java ScriptJava Script
Java Script
 
Ph
PhPh
Ph
 
How to disable text selection in blogger post
How to disable text selection in blogger postHow to disable text selection in blogger post
How to disable text selection in blogger post
 
Unit 2.4
Unit 2.4Unit 2.4
Unit 2.4
 
Thymeleaf Introduction
Thymeleaf IntroductionThymeleaf Introduction
Thymeleaf Introduction
 
WooCommerce filters
WooCommerce filtersWooCommerce filters
WooCommerce filters
 
Java Script
Java ScriptJava Script
Java Script
 

Andere mochten auch

Rohas nagpal _it_act_2000_vs_2008 - ClubHack2009
Rohas nagpal _it_act_2000_vs_2008 - ClubHack2009Rohas nagpal _it_act_2000_vs_2008 - ClubHack2009
Rohas nagpal _it_act_2000_vs_2008 - ClubHack2009ClubHack
 
Performance (Web&PHP)
Performance (Web&PHP)Performance (Web&PHP)
Performance (Web&PHP)Nuno Loureiro
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101ygv2000
 
Living With Passwords: Personal Password Management
Living With Passwords: Personal Password ManagementLiving With Passwords: Personal Password Management
Living With Passwords: Personal Password ManagementNuno Loureiro
 
Introduction to blockchain and crypto currencies
Introduction to blockchain and crypto currenciesIntroduction to blockchain and crypto currencies
Introduction to blockchain and crypto currenciesRohas Nagpal
 
The Challenge of todays CMO
The Challenge of todays CMOThe Challenge of todays CMO
The Challenge of todays CMORonald Velten
 
Website design workflow
Website design workflowWebsite design workflow
Website design workflowAhmed Bolica
 
Mobile Application Scan and Testing
Mobile Application Scan and TestingMobile Application Scan and Testing
Mobile Application Scan and TestingBlueinfy Solutions
 
Protecting Your Web Site From SQL Injection & XSS
Protecting Your Web SiteFrom SQL Injection & XSSProtecting Your Web SiteFrom SQL Injection & XSS
Protecting Your Web Site From SQL Injection & XSSskyhawk133
 
De dialoog aangaan in een massamarkt
De dialoog aangaan in een massamarktDe dialoog aangaan in een massamarkt
De dialoog aangaan in een massamarktRonald Velten
 
Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks Nuno Loureiro
 
Hackathon Tips and Tricks
Hackathon Tips and TricksHackathon Tips and Tricks
Hackathon Tips and TricksDaniel Duan
 

Andere mochten auch (20)

Android attacks
Android attacksAndroid attacks
Android attacks
 
It's no Secret
It's no SecretIt's no Secret
It's no Secret
 
C days2015
C days2015C days2015
C days2015
 
Rohas nagpal _it_act_2000_vs_2008 - ClubHack2009
Rohas nagpal _it_act_2000_vs_2008 - ClubHack2009Rohas nagpal _it_act_2000_vs_2008 - ClubHack2009
Rohas nagpal _it_act_2000_vs_2008 - ClubHack2009
 
Performance (Web&PHP)
Performance (Web&PHP)Performance (Web&PHP)
Performance (Web&PHP)
 
IPv6
IPv6IPv6
IPv6
 
JavaScript 101
JavaScript 101JavaScript 101
JavaScript 101
 
Living With Passwords: Personal Password Management
Living With Passwords: Personal Password ManagementLiving With Passwords: Personal Password Management
Living With Passwords: Personal Password Management
 
Introduction to blockchain and crypto currencies
Introduction to blockchain and crypto currenciesIntroduction to blockchain and crypto currencies
Introduction to blockchain and crypto currencies
 
The Challenge of todays CMO
The Challenge of todays CMOThe Challenge of todays CMO
The Challenge of todays CMO
 
XSS - Attacks & Defense
XSS - Attacks & DefenseXSS - Attacks & Defense
XSS - Attacks & Defense
 
Website design workflow
Website design workflowWebsite design workflow
Website design workflow
 
JS Event Model
JS Event ModelJS Event Model
JS Event Model
 
JavaScript intro
JavaScript introJavaScript intro
JavaScript intro
 
Cyber999 Brochure
Cyber999 BrochureCyber999 Brochure
Cyber999 Brochure
 
Mobile Application Scan and Testing
Mobile Application Scan and TestingMobile Application Scan and Testing
Mobile Application Scan and Testing
 
Protecting Your Web Site From SQL Injection & XSS
Protecting Your Web SiteFrom SQL Injection & XSSProtecting Your Web SiteFrom SQL Injection & XSS
Protecting Your Web Site From SQL Injection & XSS
 
De dialoog aangaan in een massamarkt
De dialoog aangaan in een massamarktDe dialoog aangaan in een massamarkt
De dialoog aangaan in een massamarkt
 
Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks Advanced SQL Injection: Attacks
Advanced SQL Injection: Attacks
 
Hackathon Tips and Tricks
Hackathon Tips and TricksHackathon Tips and Tricks
Hackathon Tips and Tricks
 

Ähnlich wie Introduction to JavaScript

Java script basics
Java script basicsJava script basics
Java script basicsJohn Smith
 
A few good JavaScript development tools
A few good JavaScript development toolsA few good JavaScript development tools
A few good JavaScript development toolsSimon Kim
 
Intro to Javascript and jQuery
Intro to Javascript and jQueryIntro to Javascript and jQuery
Intro to Javascript and jQueryShawn Calvert
 
Reliable Javascript
Reliable Javascript Reliable Javascript
Reliable Javascript Glenn Stovall
 
Even Faster Web Sites at The Ajax Experience
Even Faster Web Sites at The Ajax ExperienceEven Faster Web Sites at The Ajax Experience
Even Faster Web Sites at The Ajax ExperienceSteve Souders
 
Advanced JavaScript - Internship Presentation - Week6
Advanced JavaScript - Internship Presentation - Week6Advanced JavaScript - Internship Presentation - Week6
Advanced JavaScript - Internship Presentation - Week6Devang Garach
 
Java script Examples by Som
Java script Examples by Som  Java script Examples by Som
Java script Examples by Som Som Prakash Rai
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for JoomlaLuke Summerfield
 
How to call $scope function from console
How to call $scope function from consoleHow to call $scope function from console
How to call $scope function from consolecodeandyou forums
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)Ajay Khatri
 
What is this DI and AOP stuff anyway...
What is this DI and AOP stuff anyway...What is this DI and AOP stuff anyway...
What is this DI and AOP stuff anyway...Richard McIntyre
 
JavaScript: DOM and jQuery
JavaScript: DOM and jQueryJavaScript: DOM and jQuery
JavaScript: DOM and jQuery維佋 唐
 

Ähnlich wie Introduction to JavaScript (20)

Java script basics
Java script basicsJava script basics
Java script basics
 
A few good JavaScript development tools
A few good JavaScript development toolsA few good JavaScript development tools
A few good JavaScript development tools
 
Intro to Javascript and jQuery
Intro to Javascript and jQueryIntro to Javascript and jQuery
Intro to Javascript and jQuery
 
Reliable Javascript
Reliable Javascript Reliable Javascript
Reliable Javascript
 
wp-UNIT_III.pptx
wp-UNIT_III.pptxwp-UNIT_III.pptx
wp-UNIT_III.pptx
 
Even Faster Web Sites at The Ajax Experience
Even Faster Web Sites at The Ajax ExperienceEven Faster Web Sites at The Ajax Experience
Even Faster Web Sites at The Ajax Experience
 
Advanced JavaScript - Internship Presentation - Week6
Advanced JavaScript - Internship Presentation - Week6Advanced JavaScript - Internship Presentation - Week6
Advanced JavaScript - Internship Presentation - Week6
 
Java script Examples by Som
Java script Examples by Som  Java script Examples by Som
Java script Examples by Som
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
jQuery plugins & JSON
jQuery plugins & JSONjQuery plugins & JSON
jQuery plugins & JSON
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
 
How to call $scope function from console
How to call $scope function from consoleHow to call $scope function from console
How to call $scope function from console
 
Basics of Java Script (JS)
Basics of Java Script (JS)Basics of Java Script (JS)
Basics of Java Script (JS)
 
Jscript part1
Jscript part1Jscript part1
Jscript part1
 
What is this DI and AOP stuff anyway...
What is this DI and AOP stuff anyway...What is this DI and AOP stuff anyway...
What is this DI and AOP stuff anyway...
 
Frontin like-a-backer
Frontin like-a-backerFrontin like-a-backer
Frontin like-a-backer
 
Unit 2.4
Unit 2.4Unit 2.4
Unit 2.4
 
jQuery
jQueryjQuery
jQuery
 
JavaScript: DOM and jQuery
JavaScript: DOM and jQueryJavaScript: DOM and jQuery
JavaScript: DOM and jQuery
 

Kürzlich hochgeladen

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Kürzlich hochgeladen (20)

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Introduction to JavaScript

  • 2. The Script Tag <script> alert("My First JavaScript"); </script> Tuesday, April 16, 13
  • 4. JavaScript Statements JavaScript statements are "commands" to the browser. The purpose of the statements is to tell the browser what to do. <script> document.getElementById("demo").innerHTML="Hello"; </script> Tuesday, April 16, 13
  • 5. Semicolon ; Semicolon separates JavaScript statements. You add a semicolon at the end of each executable statement. <script> document.getElementById("demo").innerHTML="Hello"; </script> Tuesday, April 16, 13
  • 6. JavaScript Code JavaScript code (or just JavaScript) is a sequence of JavaScript statements. Each statement is executed by the browser in the sequence they are written. <script> document.getElementById("demo").innerHTML="Hello"; document.getElementById("myDIV").innerHTML="Hi"; </script> Tuesday, April 16, 13
  • 7. JavaScript Functions The purpose of a function is to make the sequence of statements execute together when called <script> function myFunction() { document.getElementById("demo").innerHTML="Hello"; document.getElementById("myDIV").innerHTML="Hi"; } </script> Tuesday, April 16, 13
  • 8. JavaScript is Case Sensitive Watch your capitalization closely when you write JavaScript statements: A function getElementById is not the same as getElementbyID. <script> function myFunction() { document.getElementById("demo").innerHTML="Hello"; document.getElementbyId("demo").innerHTML="Hello"; } </script> Tuesday, April 16, 13
  • 9. JavaScript Comments Comments will not be executed by JavaScript. Comments can be added to explain the JavaScript, or to make the code more readable. Single line comments start with //. <script> function myFunction() { // Write to a heading document.getElementById("demo").innerHTML="Hello"; } </script> Tuesday, April 16, 13
  • 10. JavaScript Comments In the following example the comment is used to prevent the execution of one of the codelines (can be suitable for debugging): <script> function myFunction() { // document.getElementById("demo").innerHTML="Hello"; } </script> Tuesday, April 16, 13
  • 11. JavaScript Functions w/Arguments When you call a function, you can pass along some values to it, these values are called arguments or parameters. These arguments can be used inside the function. You can send as many arguments as you like, separated by commas (,) <script> function myFunction(parameter1, parameter2) { document.getElementById("demo").innerHTML= parameter1; document.getElementById("myDIV").innerHTML= parameter2; } </script> Tuesday, April 16, 13
  • 12. jQuery docs.jquery.com Tuesday, April 16, 13
  • 13. jQuery jQuery commands with a call to the jQuery function. Here is how a jQuery statement is constructed. jQuery(‘p’).css(‘color’, ‘blue’); selector action parameters jQuery(‘p’) .css (‘color’, ‘blue’) Tuesday, April 16, 13
  • 14. jQuery selectors Same as CSS. Tags, Classes and IDs jQuery(‘p’).css(‘color’, ‘blue’); jQuery(‘.classname’).css(‘color’, ‘blue’); jQuery(‘#idname’).css(‘color’, ‘blue’); Tuesday, April 16, 13