SlideShare uma empresa Scribd logo
1 de 36
Baixar para ler offline
JavaScript Basic
      gugod
Tools

Firefox 3
Firebug
“shell” and “test styles” bookmarklets
 https://www.squarefree.com/
 bookmarklets/webdevel.html
“Bread board”
<html><body>
<script type=quot;text/javascriptquot;>

// Code goes here...

</script>
</body></html>
Code
Hello World

alert(quot;Hello Worldquot;);
Hello, you

var nickname = quot;gugodquot;;
alert(quot;Hello, quot; + nickname);
variables

var nickname = quot;gugodquot;;
variables

var nickname = quot;gugodquot;;
 variable
  name
variables
                   variable
                    value

var nickname = quot;gugodquot;;
 variable
  name
variables
                   variable
     declare        value

var nickname = quot;gugodquot;;
 variable
  name
Simple Variable Values
var nickname = quot;gugodquot;;
var answer = 42;

alert(nickname);
alert(answer);
Simple Variable Values
nickname = quot;gugodquot;;
answer = 42;

alert(nickname);
alert(answer);
if-else
if (answer == 42) {
    alert(quot;correctquot;);
}
else {
    alert(quot;wrongquot;);
}
Expressions
   a   == b
   a   != b
   a   >= b
   a   <= b
   a   > b
   a   < b
   a
Function

var hello = function() {
    alert(quot;helloquot;);
}
Function

function hello() {
    alert(quot;helloquot;);
}
Function w/ Argument

 var hello = function(nickname) {
     alert(quot;hello quot; + nickname);
 }
var hello = function(nickname, like) {
    var message = quot;hello quot; + nickname;

    if (like > 6) {
      message = quot;Great to see you, quot;
        + nickname;
    }

    if (like < 2){
       message = quot;Oh, it’s you, quot;
         + nickname;
    }

    alert(message);
}
Input
Browser User Input

 prompt()

DOM (HTML)

Ajax (XMLHttpRequest)

 JSONRequest, JSONP, ...
prompt

var a = prompt(quot;Give me money:quot;);

alert(a);
prompt
Good
 Easy
 Built-in
Bad
 No way to customize style
 One variable at a time
DOM
<html><body>
<span id=quot;nicknamequot;>gugod</span>
<script type=quot;text/javascriptquot;>

// Code...

</script>
</body></html>
<html><body>
<span id=quot;nicknamequot;>gugod</span>
<script type=quot;text/javascriptquot;>

var nickname =
  document.getElementById(quot;nicknamequot;)
  .childNodes[0]
  .nodeValue;

alert(nickname);

</script>
</body></html>
Add jQuery
<head>
  <script
    type=quot;text/javascriptquot;
    src=quot;jquery.min.jsquot;></script>
</head>
Hello (jQuery)
<html>
<head>
  <script type=quot;text/javascriptquot;
      src=quot;jquery.jsquot;></script>
</head>
<body>
<span id=quot;nicknamequot;>gugod</span>
<script type=quot;text/javascriptquot;>

var nickname = $(quot;#nicknamequot;).text();

alert(nickname);

</script>
</body></html>
Output
Browser Built-in

 alert()

DOM

Ajax

 HTTP POST
DOM
<span id=quot;outputquot;></span>

<script type=quot;text/javascriptquot;>

var message = quot;Hello, worldquot;;

$(quot;#outputquot;).text(message);

</script>
Input + Output

<span id=quot;outputquot;></span>
<script type=quot;text/javascriptquot;>

var message = quot;Hello, quot; + prompt(quot;Your name is: quot;);

$(quot;#outputquot;).text(message);

</script>
Other Topics
Effect
jQuery hide

<div id=quot;helloquot;>Hello</div>
<script type=quot;text/javascriptquot;>

$(quot;#helloquot;).hide('slow');

</script>
Hide on click
<a href=quot;#quot; id=quot;closequot;>Close</a>
<div id=quot;helloquot;>Hello</div>

<script type=quot;text/javascriptquot;>
$(quot;#closequot;).click(function() {
    $(quot;#helloquot;).hide('slow');
});
</script>
More Info

http://jquery.com/
 http://visualjquery.com/
https://www.squarefree.com/
bookmarklets/webdevel.html
The End

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Javascript
JavascriptJavascript
Javascript
 
3. Java Script
3. Java Script3. Java Script
3. Java Script
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
Javascript functions
Javascript functionsJavascript functions
Javascript functions
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overview
 
Java script
Java scriptJava script
Java script
 
Java script
Java scriptJava script
Java script
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - Components
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
jQuery
jQueryjQuery
jQuery
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
 
Css ppt
Css pptCss ppt
Css ppt
 
Class 3 - PHP Functions
Class 3 - PHP FunctionsClass 3 - PHP Functions
Class 3 - PHP Functions
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
CSS
CSSCSS
CSS
 

Semelhante a Javascript Basic

Solr and symfony in Harmony with SolrJs
Solr and symfony in Harmony with SolrJsSolr and symfony in Harmony with SolrJs
Solr and symfony in Harmony with SolrJs
Wildan Maulana
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
Wen-Tien Chang
 
Html and i_phone_mobile-2
Html and i_phone_mobile-2Html and i_phone_mobile-2
Html and i_phone_mobile-2
tonvanbart
 
Lecture 5 - Comm Lab: Web @ ITP
Lecture 5 - Comm Lab: Web @ ITPLecture 5 - Comm Lab: Web @ ITP
Lecture 5 - Comm Lab: Web @ ITP
yucefmerhi
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
BG Java EE Course
 

Semelhante a Javascript Basic (20)

Java Script
Java ScriptJava Script
Java Script
 
CSIS 138 Javascript Class1
CSIS 138 Javascript Class1CSIS 138 Javascript Class1
CSIS 138 Javascript Class1
 
JQuery 101
JQuery 101JQuery 101
JQuery 101
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax components
 
Couch Db.0.9.0.Pub
Couch Db.0.9.0.PubCouch Db.0.9.0.Pub
Couch Db.0.9.0.Pub
 
Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2
 
Ajax On S2 Odp
Ajax On S2 OdpAjax On S2 Odp
Ajax On S2 Odp
 
Seam Glassfish Slidecast
Seam Glassfish SlidecastSeam Glassfish Slidecast
Seam Glassfish Slidecast
 
Introduction To Lamp
Introduction To LampIntroduction To Lamp
Introduction To Lamp
 
JWU Guest Talk: JavaScript and AJAX
JWU Guest Talk: JavaScript and AJAXJWU Guest Talk: JavaScript and AJAX
JWU Guest Talk: JavaScript and AJAX
 
Solr and symfony in Harmony with SolrJs
Solr and symfony in Harmony with SolrJsSolr and symfony in Harmony with SolrJs
Solr and symfony in Harmony with SolrJs
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
 
Html and i_phone_mobile-2
Html and i_phone_mobile-2Html and i_phone_mobile-2
Html and i_phone_mobile-2
 
Merb jQuery
Merb jQueryMerb jQuery
Merb jQuery
 
Front End on Rails
Front End on RailsFront End on Rails
Front End on Rails
 
Lecture 5 - Comm Lab: Web @ ITP
Lecture 5 - Comm Lab: Web @ ITPLecture 5 - Comm Lab: Web @ ITP
Lecture 5 - Comm Lab: Web @ ITP
 
Page Caching Resurrected
Page Caching ResurrectedPage Caching Resurrected
Page Caching Resurrected
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Ajax ons2
Ajax ons2Ajax ons2
Ajax ons2
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
 

Mais de Kang-min Liu

Elasticsearch 實戰介紹
Elasticsearch 實戰介紹Elasticsearch 實戰介紹
Elasticsearch 實戰介紹
Kang-min Liu
 
Same but Different
Same but DifferentSame but Different
Same but Different
Kang-min Liu
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
Kang-min Liu
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
Kang-min Liu
 

Mais de Kang-min Liu (19)

o̍h Tai-gi
o̍h Tai-gio̍h Tai-gi
o̍h Tai-gi
 
The architecture of search engines in Booking.com
The architecture of search engines in Booking.comThe architecture of search engines in Booking.com
The architecture of search engines in Booking.com
 
Elasticsearch 實戰介紹
Elasticsearch 實戰介紹Elasticsearch 實戰介紹
Elasticsearch 實戰介紹
 
Perlbrew
PerlbrewPerlbrew
Perlbrew
 
Same but Different
Same but DifferentSame but Different
Same but Different
 
perlbrew yapcasia 2010
perlbrew yapcasia 2010perlbrew yapcasia 2010
perlbrew yapcasia 2010
 
Git
GitGit
Git
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
Learning From Ruby (Yapc Asia)
Learning From Ruby (Yapc Asia)Learning From Ruby (Yapc Asia)
Learning From Ruby (Yapc Asia)
 
YAPC::Tiny Introduction
YAPC::Tiny IntroductionYAPC::Tiny Introduction
YAPC::Tiny Introduction
 
Integration Test With Cucumber And Webrat
Integration Test With Cucumber And WebratIntegration Test With Cucumber And Webrat
Integration Test With Cucumber And Webrat
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
Javascript Tutorial
Javascript TutorialJavascript Tutorial
Javascript Tutorial
 
Handlino - RandomLife
Handlino - RandomLifeHandlino - RandomLife
Handlino - RandomLife
 
Jformino
JforminoJformino
Jformino
 
Test Continuous
Test ContinuousTest Continuous
Test Continuous
 
網頁程式還可以怎麼設計
網頁程式還可以怎麼設計網頁程式還可以怎麼設計
網頁程式還可以怎麼設計
 
OSDC.tw 2008 Lightening Talk
OSDC.tw 2008 Lightening TalkOSDC.tw 2008 Lightening Talk
OSDC.tw 2008 Lightening Talk
 
Happy Designer 20080329
Happy Designer 20080329Happy Designer 20080329
Happy Designer 20080329
 

Último

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 

Último (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 

Javascript Basic