JQuery

Jussi Pohjolainen
Jussi PohjolainenSenior Lecturer à Tampere University of Applied Sciences
Short into to JQuery

         Jussi Pohjolainen
Tampere University of Applied Sciences
JQuery?
• Motivation
  – Simple things may require lot of coding
  – Common browsers are different and
    implementation varies
• Solution, use a framework
  – jQuery is a fast and concise JavaScript Library that
    simplifies HTML document traversing, event
    handling, animating, and Ajax interactions for
    rapid web development.
How?
• Download JQuery file (http://jquery.com/)
  – http://code.jquery.com/jquery-1.7.1.min.js
• Make your xhtml page and reference to the
  file in script block
• Make your code and use JQuery functions!
<script type="text/javascript" src="jquery.js"></script>

 <script type="text/javascript">
 //<![CDATA[

  // When document is ready to be manipulated
  jQuery(document).ready( pageReadyToBeManipulated );

  function pageReadyToBeManipulated() {
     // If link is clicked
     jQuery("a").click( linkClick );
  }

  function linkClick(event) {
     alert("Thanks for visiting!");
     // Prevent the default action
     event.preventDefault();
  }

 //]]>
 </script>
Some Basic Syntax
• JQuery can be used in two ways:
  – JQuery()
  – Or
  – $()
• $ is an alias to JQuery()! $ more commonly
  used
<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">
//<![CDATA[

// When document is ready to be manipulated
$(document).ready( pageReadyToBeManipulated );

function pageReadyToBeManipulated() {
   // If link is clicked
   $("a").click( linkClick );
}

function linkClick(event) {
   alert("Thanks for visiting!");
   // Prevent the default action
   event.preventDefault();
}

//]]>
</script>
// USING ANONYMOUS FUNCTIONS

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">
//<![CDATA[

 $(document).ready(function(){
     $("a").click(function(event){
         alert("Thanks for visiting!");
         event.preventDefault();
     });
 });

//]]>
</script>
// EVEN SHORTER SYNTAX, FORGET THE DOCUMENT
PARAMETER

<script type="text/javascript" src="jquery.js"></script>

 <script type="text/javascript">
 //<![CDATA[

 $().ready(function(){
     $("a").click(function(event){
         alert("Thanks for visiting!");
         event.preventDefault();
     });
 });

 //]]>
 </script>
Getters in the Traditional Way
• getElementsById

• getElementsByTagName

• getAttribute
JQuery and Selectors
• Select all h1 elements
  – $(“h1”)
• Select the first one
  – $(“h1”)*0+
• Add contents
  – $(“h1”)*0+.innerHTML = “hello!”;
• Lot of different selectors
  – http://api.jquery.com/category/selectors/
Creating Elements in Traditional Way

•   createElement
•   createTextNode
•   setAttribute
•   appendChild
•   removeChild
JQuery Insert
$().ready(function(){
     $("a").click(function(event){

              // Insert the new element after element with id here
              $("<p>New Element</p>").insertAfter("#here");

              event.preventDefault();
        });
  });
Manipulation Functions
•   .addClass()
•   .after()
•   .append()
•   .css()
•   …
•   See:
    http://api.jquery.com/category/manipulation/
Some Effects: Lot of Anim Functions
$('#clickme').click(function() {
  $('#book').slideUp('slow', function() {
    // Animation complete.
  });
});
1 sur 14

Recommandé

State of jQuery and Drupal par
State of jQuery and DrupalState of jQuery and Drupal
State of jQuery and Drupaljeresig
1.3K vues21 diapositives
Jqeury ajax plugins par
Jqeury ajax pluginsJqeury ajax plugins
Jqeury ajax pluginsInbal Geffen
366 vues9 diapositives
Introduction to jQuery - Barcamp London 9 par
Introduction to jQuery - Barcamp London 9Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9Jack Franklin
612 vues29 diapositives
Railsbridge javascript par
Railsbridge   javascriptRailsbridge   javascript
Railsbridge javascriptp4geoff
185 vues15 diapositives
jQuery in the [Aol.] Enterprise par
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterpriseDave Artz
6K vues65 diapositives

Contenu connexe

Tendances

Advanced jQuery (Ajax Exp 2007) par
Advanced jQuery (Ajax Exp 2007)Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)jeresig
1.3K vues8 diapositives
JavaScript and jQuery Basics par
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery BasicsKaloyan Kosev
3.5K vues17 diapositives
Quick Intro to JQuery and JQuery Mobile par
Quick Intro to JQuery and JQuery MobileQuick Intro to JQuery and JQuery Mobile
Quick Intro to JQuery and JQuery MobileJussi Pohjolainen
1.1K vues19 diapositives
Jquery presentation par
Jquery presentationJquery presentation
Jquery presentationMevin Mohan
44 vues18 diapositives
Advanced JQuery Mobile tutorial with Phonegap par
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Rakesh Jha
2.9K vues163 diapositives
Dart and AngularDart par
Dart and AngularDartDart and AngularDart
Dart and AngularDartLoc Nguyen
1K vues31 diapositives

Tendances(18)

Advanced jQuery (Ajax Exp 2007) par jeresig
Advanced jQuery (Ajax Exp 2007)Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)
jeresig1.3K vues
JavaScript and jQuery Basics par Kaloyan Kosev
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
Kaloyan Kosev3.5K vues
Advanced JQuery Mobile tutorial with Phonegap par Rakesh Jha
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap
Rakesh Jha2.9K vues
Dart and AngularDart par Loc Nguyen
Dart and AngularDartDart and AngularDart
Dart and AngularDart
Loc Nguyen1K vues
Understanding backbonejs par Nick Lee
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
Nick Lee2.6K vues
Auto tools par 祺 周
Auto toolsAuto tools
Auto tools
祺 周313 vues
Client-side Transformations par John Boxall
Client-side TransformationsClient-side Transformations
Client-side Transformations
John Boxall228 vues
Introduction to jQuery (Ajax Exp 2006) par jeresig
Introduction to jQuery (Ajax Exp 2006)Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)
jeresig2.4K vues
Javascript and jQuery intro par waw325
Javascript and jQuery introJavascript and jQuery intro
Javascript and jQuery intro
waw325616 vues
Don't Worry jQuery is very Easy:Learning Tips For jQuery par shabab shihan
Don't Worry jQuery is very Easy:Learning Tips For jQueryDon't Worry jQuery is very Easy:Learning Tips For jQuery
Don't Worry jQuery is very Easy:Learning Tips For jQuery
shabab shihan819 vues
JavaScript Library Overview (Ajax Exp West 2007) par jeresig
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
jeresig1.4K vues

Similaire à JQuery

Short intro to JQuery and Modernizr par
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and ModernizrJussi Pohjolainen
5.4K vues22 diapositives
J Query (Complete Course) by Muhammad Ehtisham Siddiqui par
J Query (Complete Course) by Muhammad Ehtisham SiddiquiJ Query (Complete Course) by Muhammad Ehtisham Siddiqui
J Query (Complete Course) by Muhammad Ehtisham SiddiquiMuhammad Ehtisham Siddiqui
244 vues37 diapositives
J query training par
J query trainingJ query training
J query trainingFIS - Fidelity Information Services
429 vues33 diapositives
Building iPhone Web Apps using "classic" Domino par
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoRob Bontekoe
1.6K vues21 diapositives
jQuery for web development par
jQuery for web developmentjQuery for web development
jQuery for web developmentiFour Institute - Sustainable Learning
316 vues40 diapositives

Similaire à JQuery(20)

Building iPhone Web Apps using "classic" Domino par Rob Bontekoe
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
Rob Bontekoe1.6K vues
Introduction to jquery mobile with Phonegap par Rakesh Jha
Introduction to jquery mobile with PhonegapIntroduction to jquery mobile with Phonegap
Introduction to jquery mobile with Phonegap
Rakesh Jha979 vues
Jquery Complete Presentation along with Javascript Basics par EPAM Systems
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
EPAM Systems4.8K vues
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group) par Doris Chen
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
Doris Chen9.5K vues
Learning jQuery made exciting in an interactive session by one of our team me... par Thinqloud
Learning jQuery made exciting in an interactive session by one of our team me...Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...
Thinqloud 790 vues
SharePoint & jQuery Guide - SPSNashville 2014 par Mark Rackley
SharePoint & jQuery Guide - SPSNashville 2014SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014
Mark Rackley953 vues
How to increase Performance of Web Application using JQuery par kolkatageeks
How to increase Performance of Web Application using JQueryHow to increase Performance of Web Application using JQuery
How to increase Performance of Web Application using JQuery
kolkatageeks1.9K vues
JQuery UI par Gary Yeh
JQuery UIJQuery UI
JQuery UI
Gary Yeh1.2K vues

Plus de Jussi Pohjolainen

Moved to Speakerdeck par
Moved to SpeakerdeckMoved to Speakerdeck
Moved to SpeakerdeckJussi Pohjolainen
1.7K vues1 diapositive
Java Web Services par
Java Web ServicesJava Web Services
Java Web ServicesJussi Pohjolainen
1.7K vues194 diapositives
Box2D and libGDX par
Box2D and libGDXBox2D and libGDX
Box2D and libGDXJussi Pohjolainen
3.1K vues28 diapositives
libGDX: Screens, Fonts and Preferences par
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferencesJussi Pohjolainen
2.2K vues17 diapositives
libGDX: Tiled Maps par
libGDX: Tiled MapslibGDX: Tiled Maps
libGDX: Tiled MapsJussi Pohjolainen
3.6K vues33 diapositives
libGDX: User Input and Frame by Frame Animation par
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame AnimationJussi Pohjolainen
2.8K vues33 diapositives

Plus de Jussi Pohjolainen(20)

libGDX: User Input and Frame by Frame Animation par Jussi Pohjolainen
libGDX: User Input and Frame by Frame AnimationlibGDX: User Input and Frame by Frame Animation
libGDX: User Input and Frame by Frame Animation
Jussi Pohjolainen2.8K vues
Intro to Building Android Games using libGDX par Jussi Pohjolainen
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
Jussi Pohjolainen2.9K vues
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures par Jussi Pohjolainen
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Jussi Pohjolainen1.1K vues

Dernier

Cencora Executive Symposium par
Cencora Executive SymposiumCencora Executive Symposium
Cencora Executive Symposiummarketingcommunicati21
160 vues14 diapositives
The Power of Heat Decarbonisation Plans in the Built Environment par
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built EnvironmentIES VE
84 vues20 diapositives
Mobile Core Solutions & Successful Cases.pdf par
Mobile Core Solutions & Successful Cases.pdfMobile Core Solutions & Successful Cases.pdf
Mobile Core Solutions & Successful Cases.pdfIPLOOK Networks
14 vues7 diapositives
Choosing the Right Flutter App Development Company par
Choosing the Right Flutter App Development CompanyChoosing the Right Flutter App Development Company
Choosing the Right Flutter App Development CompanyFicode Technologies
13 vues9 diapositives
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell par
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
"Node.js vs workers — A comparison of two JavaScript runtimes", James M SnellFwdays
14 vues30 diapositives
"Running students' code in isolation. The hard way", Yurii Holiuk par
"Running students' code in isolation. The hard way", Yurii Holiuk "Running students' code in isolation. The hard way", Yurii Holiuk
"Running students' code in isolation. The hard way", Yurii Holiuk Fwdays
36 vues34 diapositives

Dernier(20)

The Power of Heat Decarbonisation Plans in the Built Environment par IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE84 vues
Mobile Core Solutions & Successful Cases.pdf par IPLOOK Networks
Mobile Core Solutions & Successful Cases.pdfMobile Core Solutions & Successful Cases.pdf
Mobile Core Solutions & Successful Cases.pdf
IPLOOK Networks14 vues
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell par Fwdays
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
"Node.js vs workers — A comparison of two JavaScript runtimes", James M Snell
Fwdays14 vues
"Running students' code in isolation. The hard way", Yurii Holiuk par Fwdays
"Running students' code in isolation. The hard way", Yurii Holiuk "Running students' code in isolation. The hard way", Yurii Holiuk
"Running students' code in isolation. The hard way", Yurii Holiuk
Fwdays36 vues
What is Authentication Active Directory_.pptx par HeenaMehta35
What is Authentication Active Directory_.pptxWhat is Authentication Active Directory_.pptx
What is Authentication Active Directory_.pptx
HeenaMehta3515 vues
PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」 par PC Cluster Consortium
PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」
PCCC23:日本AMD株式会社 テーマ1「AMD Instinct™ アクセラレーターの概要」
AIM102-S_Cognizant_CognizantCognitive par PhilipBasford
AIM102-S_Cognizant_CognizantCognitiveAIM102-S_Cognizant_CognizantCognitive
AIM102-S_Cognizant_CognizantCognitive
PhilipBasford21 vues
"Package management in monorepos", Zoltan Kochan par Fwdays
"Package management in monorepos", Zoltan Kochan"Package management in monorepos", Zoltan Kochan
"Package management in monorepos", Zoltan Kochan
Fwdays34 vues
The Role of Patterns in the Era of Large Language Models par Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li91 vues
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」 par PC Cluster Consortium
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」
NTGapps NTG LowCode Platform par Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu437 vues
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... par The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
Cocktail of Environments. How to Mix Test and Development Environments and St... par Aleksandr Tarasov
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...
The Power of Generative AI in Accelerating No Code Adoption.pdf par Saeed Al Dhaheri
The Power of Generative AI in Accelerating No Code Adoption.pdfThe Power of Generative AI in Accelerating No Code Adoption.pdf
The Power of Generative AI in Accelerating No Code Adoption.pdf

JQuery

  • 1. Short into to JQuery Jussi Pohjolainen Tampere University of Applied Sciences
  • 2. JQuery? • Motivation – Simple things may require lot of coding – Common browsers are different and implementation varies • Solution, use a framework – jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
  • 3. How? • Download JQuery file (http://jquery.com/) – http://code.jquery.com/jquery-1.7.1.min.js • Make your xhtml page and reference to the file in script block • Make your code and use JQuery functions!
  • 4. <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> //<![CDATA[ // When document is ready to be manipulated jQuery(document).ready( pageReadyToBeManipulated ); function pageReadyToBeManipulated() { // If link is clicked jQuery("a").click( linkClick ); } function linkClick(event) { alert("Thanks for visiting!"); // Prevent the default action event.preventDefault(); } //]]> </script>
  • 5. Some Basic Syntax • JQuery can be used in two ways: – JQuery() – Or – $() • $ is an alias to JQuery()! $ more commonly used
  • 6. <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> //<![CDATA[ // When document is ready to be manipulated $(document).ready( pageReadyToBeManipulated ); function pageReadyToBeManipulated() { // If link is clicked $("a").click( linkClick ); } function linkClick(event) { alert("Thanks for visiting!"); // Prevent the default action event.preventDefault(); } //]]> </script>
  • 7. // USING ANONYMOUS FUNCTIONS <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> //<![CDATA[ $(document).ready(function(){ $("a").click(function(event){ alert("Thanks for visiting!"); event.preventDefault(); }); }); //]]> </script>
  • 8. // EVEN SHORTER SYNTAX, FORGET THE DOCUMENT PARAMETER <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> //<![CDATA[ $().ready(function(){ $("a").click(function(event){ alert("Thanks for visiting!"); event.preventDefault(); }); }); //]]> </script>
  • 9. Getters in the Traditional Way • getElementsById • getElementsByTagName • getAttribute
  • 10. JQuery and Selectors • Select all h1 elements – $(“h1”) • Select the first one – $(“h1”)*0+ • Add contents – $(“h1”)*0+.innerHTML = “hello!”; • Lot of different selectors – http://api.jquery.com/category/selectors/
  • 11. Creating Elements in Traditional Way • createElement • createTextNode • setAttribute • appendChild • removeChild
  • 12. JQuery Insert $().ready(function(){ $("a").click(function(event){ // Insert the new element after element with id here $("<p>New Element</p>").insertAfter("#here"); event.preventDefault(); }); });
  • 13. Manipulation Functions • .addClass() • .after() • .append() • .css() • … • See: http://api.jquery.com/category/manipulation/
  • 14. Some Effects: Lot of Anim Functions $('#clickme').click(function() { $('#book').slideUp('slow', function() { // Animation complete. }); });

Notes de l'éditeur

  1. &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;head&gt; &lt;title&gt;Hello World - JQuery&lt;/title&gt; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;application/xhtml+xml; charset=utf-8&quot;/&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt; //&lt;![CDATA[ // When document is ready to be manipulatedjQuery(document).ready( pageReadyToBeManipulated ); function pageReadyToBeManipulated() { // If link is clickedjQuery(&quot;a&quot;).click( linkClick ); } function linkClick(event) { alert(&quot;Thanks for visiting!&quot;); // Prevent the default actionevent.preventDefault(); } //]]&gt; &lt;/script&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;http://www.google.com&quot;&gt;Google&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;
  2. &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;head&gt; &lt;title&gt;Hello World - JQuery&lt;/title&gt; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;application/xhtml+xml; charset=utf-8&quot;/&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt; //&lt;![CDATA[ // When document is ready to be manipulated $(document).ready( pageReadyToBeManipulated ); function pageReadyToBeManipulated() { // If link is clicked $(&quot;a&quot;).click( linkClick ); } function linkClick(event) { alert(&quot;Thanks for visiting!&quot;); // Prevent the default actionevent.preventDefault(); } //]]&gt; &lt;/script&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;http://www.google.com&quot;&gt;Google&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;
  3. &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;head&gt; &lt;title&gt;Hello World - JQuery&lt;/title&gt; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;application/xhtml+xml; charset=utf-8&quot;/&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt; //&lt;![CDATA[ $(document).ready(function(){ $(&quot;a&quot;).click(function(event){ alert(&quot;Thanks for visiting!&quot;);event.preventDefault(); }); }); //]]&gt; &lt;/script&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;http://www.google.com&quot;&gt;Google&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;
  4. &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;head&gt; &lt;title&gt;Hello World - JQuery&lt;/title&gt; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;application/xhtml+xml; charset=utf-8&quot;/&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt; //&lt;![CDATA[ $(document).ready(function(){ $(&quot;a&quot;).click(function(event){ alert(&quot;Thanks for visiting!&quot;);event.preventDefault(); }); }); //]]&gt; &lt;/script&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;http://www.google.com&quot;&gt;Google&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;
  5. &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;head&gt; &lt;title&gt;Hello World - JQuery&lt;/title&gt; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;application/xhtml+xml; charset=utf-8&quot;/&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt; //&lt;![CDATA[ $().ready(function(){ $(&quot;a&quot;).click(function(event){ $(&quot;h1&quot;)[0].innerHTML = &quot;New Title!&quot;;event.preventDefault(); }); }); //]]&gt; &lt;/script&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;Example&lt;/h1&gt;&lt;p&gt;&lt;a href=&quot;&quot;&gt;Change Title!&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;
  6. &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;head&gt; &lt;title&gt;Hello World - JQuery&lt;/title&gt; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;application/xhtml+xml; charset=utf-8&quot;/&gt; &lt;script type=&quot;text/javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt; //&lt;![CDATA[ $().ready(function(){ $(&quot;a&quot;).click(function(event){ $(&quot;&lt;p&gt;New Element&lt;/p&gt;&quot;).insertAfter(&quot;#here&quot;);event.preventDefault(); }); }); //]]&gt; &lt;/script&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;Example&lt;/h1&gt;&lt;p&gt;&lt;a href=&quot;&quot;&gt;Add element!&lt;/a&gt;&lt;/p&gt;&lt;div id=&quot;here&quot;&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;