SlideShare a Scribd company logo
Introduction of HTML/CSS/JS


            Ruchi Agarwal
          Software Consultant
           Knoldus Software
What is HTML?


โ—   HTML is a language for describing web pages.
โ—   HTML stands for Hyper Text Markup Language
โ—   HTML is a markup language
โ—   A markup language is a set of markup tags
โ—   The tags describe document content
โ—   HTML documents contain HTML tags and plain text
โ—   HTML documents are also called web pages
HTML Tags


โ—   HTML markup tags are usually called HTML tags
โ—   HTML tags are keywords (tag names) surrounded by angle brackets like <html>
โ—   HTML tags normally come in pairs like <b> and </b>
โ—   The first tag in a pair is the start tag, the second tag is the end tag
โ—   The end tag is written like the start tag, with a forward slash before the tag name
โ—   Start and end tags are also called opening tags and closing tags


              <tagname>content</tagname>
Basic HTML page structure
Example
What is CSS?


โ—   CSS stands for Cascading Style Sheets
โ—   Styles define how to display HTML elements
โ—   Styles were added to HTML 4.0 to solve a problem
โ—   External Style Sheets can save a lot of work
โ—   External Style Sheets are stored in CSS files
โ—   A CSS (cascading style sheet) file allows to separate web sites HTML content from itโ€™s
    style.
How to use CSS?
There are three ways of inserting a style sheet:
External Style Sheet:
    An external style sheet is ideal when the style is applied to many pages.
    <head>
         <link rel="stylesheet" type="text/css" href="mystyle.css">
    </head>


Internal Style Sheet:
    An internal style sheet should be used when a single document has a unique style.
    <head>
    <style>
         p {margin-left:20px;}
         body {background-image:url("images/back40.gif");}
    </style>
    </head>
Inline Styles:
    To use inline styles use the style attribute in the relevant tag. The style attribute can
contain any CSS property.


         <p style="color:#fafafa;margin-left:20px">This is a paragraph.</p>


Multiple Styles Will Cascade into One:
Cascading order


         โ—   Inline style (inside an HTML element)
         โ—   Internal style sheet (in the head section)
         โ—   External style sheet
         โ—   Browser default
CSS Syntax


       A CSS rule has two main parts: a selector, and one or more declarations:




Combining Selectors


        h1, h2, h3, h4, h5, h6 {
              color: #009900;
              font-family: Georgia, sans-serif;
        }
The id Selector
    The id selector is used to specify a style for a single, unique element.
    The id selector uses the id attribute of the HTML element, and is defined with a "#".


    Syntax
             #selector-id      {   property : value ; }




The class Selector
    The class selector is used to specify a style for a group of elements.
    The class selector uses the HTML class attribute, and is defined with a "."


    Syntax
             .selector-class       {    property : value ;   }
CSS Anchors, Links and Pseudo Classes:


   Below are the various ways you can use CSS to style links.


       a:link {color: #009900;}
       a:visited {color: #999999;}
       a:hover {color: #333333;}
       a:focus {color: #333333;}
       a:active {color: #009900;}
The CSS Box Model
โ—   All HTML elements can be considered as boxes. In CSS, the term "box model" is used when
    talking about design and layout.


โ—   The CSS box model is essentially a box that wraps around HTML elements, and it consists of:
        margins, borders, padding, and the actual content.


โ—   The box model allows to place a border around elements and space elements in relation to
    other elements.
Example


     #signup-form {                          #signup-form .fieldgroup input, #signup-form
       background-color: #F8FDEF;            .fieldgroup textarea, #signup-form
       border: 1px solid #DFDCDC;            .fieldgroup select {
       border-radius: 15px 15px 15px 15px;       float: right;
       display: inline-block;                    margin: 10px 0;
       margin-bottom: 30px;                      height: 25px;
       margin-left: 20px;                    }
       margin-top: 10px;
       padding: 25px 50px 10px;              #signup-form .submit {
       width: 350px;                           padding: 10px;
     }                                         width: 220px;
                                               height: 40px !important;
     #signup-form .fieldgroup {              }
       display: inline-block;
       padding: 8px 10px;                    #signup-form .fieldgroup label.error {
       width: 340px;                           color: #FB3A3A;
     }                                         display: inline-block;
                                               margin: 4px 0 5px 125px;
     #signup-form .fieldgroup label {          padding: 0;
       float: left;                            text-align: left;
       padding: 15px 0 0;                      width: 220px;
       text-align: right;                    }
       width: 110px;
     }
What is JavaScript

โ—   JavaScript is a Scripting Language
โ—   A scripting language is a lightweight programming language.
โ—   JavaScript is programming code that can be inserted into HTML pages.
โ—   JavaScript inserted into HTML pages, can be executed by all modern web browsers.
How to use JavaScript?

The <script> Tag
To insert a JavaScript into an HTML page, use the <script> tag.
The <script> and </script> tells where the JavaScript starts and ends.
    <script>
         alert("My First JavaScript");
    </script>


JavaScript in <body>
    <html>
    <body>
    <script>
         document.write("<h1>This is a heading</h1>");
    </script>
    </body>
    </html>
External JavaScripts
Scripts can also be placed in external files. External files often contain code to be used by
several different web pages.
External JavaScript files have the file extension .js.
To use an external script, point to the .js file in the "src" attribute of the <script> tag:


         <html>
         <body>
              <script src="myScript.js"></script>
         </body>
         </html>
The HTML DOM (Document Object Model)


    When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects:
Finding HTML Elements by Id


       document.getElementById("<id-name>");


Finding HTML Elements by Tag Name


       document.getElementsByTagName("<tag>");


Finding HTML Elements by Name


       document.getElementsByName(โ€œ<name-attr>โ€)


Finding HTML Elements by Class


       document.getElementByClass(โ€œ<class-name>โ€)
Writing Into HTML Output


    document.write("<h1>This is a heading</h1>");
    document.write("<p>This is a paragraph</p>");


Reacting to Events


    <button type="button" onclick="alert('Welcome!')">Click Me!</button>


Changing HTML Content
Using JavaScript to manipulate the content of HTML elements is a very powerful functionality.


    x=document.getElementById("demo")            //Find the element
    x.innerHTML="Hello JavaScript";              //Change the content
Changing HTML Styles
Changing the style of an HTML element, is a variant of changing an HTML attribute.


        x=document.getElementById("demo")           //Find the element
        x.style.color="#ff0000";                    //Change the style


Validate Input
JavaScript is commonly used to validate input.


        if isNaN(x) {alert("Not Numeric")};
Example

          function validateForm()
          {
               var nameValue=document.getElementById('name');
               verifyName(nameValue);
               var emailValue=document.getElementById('email');
               verifyEmail(emailValue);
               var password=document.getElementById('password');
               verifyPassword(password,8,12);
          }

          function verifyName(uname)
          {

              var letters = /^[A-Za-z]+$/;
              if(uname.value.match(letters))
              {
                    return true;
              }
              else
              {
                    alert('Invalid name');
                    return false;
              }
          }
What is jQuery?


 โ—   jQuery is a lightweight, "write less, do more", JavaScript library.
 โ—   The purpose of jQuery is to make it much easier to use JavaScript on your website.
 โ—   jQuery takes a lot of common tasks that requires many lines of JavaScript code to
     accomplish, and wraps it into methods that you can call with a single line of code.
 โ—   jQuery also simplifies a lot of the complicated things from JavaScript, like AJAX calls and
     DOM manipulation.


Features:
 โ—   HTML/DOM manipulation
 โ—   CSS manipulation
 โ—   HTML event methods
 โ—   Effects and animations
 โ—   AJAX
jQuery Syntax
Basic syntax:
                   $(selector).action()


 โ—   A $ sign to define/access jQuery
 โ—   A (selector) to "query (or find)" HTML elements
 โ—   A jQuery action() to be performed on the element(s)


Example:
                  $("p").hide() - hides all <p> elements.
How to use Jquery:
     <head>
         <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
     </head>
jQuery Selectors:
    jQuery selectors allow you to select and manipulate HTML element(s).


The element , id and class Selector
    The jQuery element selector selects elements based on their tag names.
                         $("<tag-name>")             //element selector
                         $("#<id-name>")             // id selector
                         $(".<class-name>")          // class selector
Example
          $(document).ready(function(){
                $("button").click(function(){
                      $("p").hide();
                      $("#test").hide();        //#id selector
                      $(".test").hide();        //.class selector
                });
          });
Example
jQuery Event


All the different visitors actions that a web page can respond to are called events.
An event represents the precise moment when something happens.


    Mouse Events Keyboard Events             Form Events    Document/Window Events

       click              keypress              submit                 load
       dblclick           keydown               change                resize
     mouseenter           keyup                  focus                scroll

     mouseleave                                   blur                unload




Example:          $("p").click(function(){
                        // action goes here!!
                  });
JQuery Effects:


JQuery hide(), show() and toggle() method


        $(selector).hide(speed,callback);
        $(selector).show(speed,callback);
        $(selector).toggle(speed,callback);


jQuery fadeIn() , fadeOut() ,fadeToggle() and fadeTo() method


        $(selector).fadeIn(speed,callback);
        $(selector).fadeOut(speed,callback);
        $(selector).fadeToggle(speed,callback);
        $(selector).fadeTo(speed,callback);
jQuery Sliding Methods


        $(selector).slideDown(speed,callback);
        $(selector).slideUp(speed,callback);
        $(selector).slideToggle(speed,callback);


jQuery Animations - The animate() Method


        $(selector).animate({params},speed,callback);


jQuery stop() Method


        $(selector).stop(stopAll,goToEnd);
jQuery Method Chaining


            $(selector).css("color","red").slideUp(2000).slideDown(2000);




jQuery - Get Content and Attributes


            $(selector).click(function(){
                  alert("Text: " + $(selector).text());
                  alert("HTML: " + $(selector).html());
                  alert("Value: " + $(input-selector).val());
                  alert($(link-selector).attr("href"));
            });
jQuery - Set Content and Attributes


        $(selector).click(function(){
                   $(selector).text("Hello world!");
                   $(selector).html("<b>Hello world!</b>");
                   $(input-selector).val("Dolly Duck");
                   $(link-selector).attr("href","http://www.google.comโ€);
        });


jQuery - Add Elements


        $(selector).append("Some appended text.");
        $(selector).prepend("Some prepended text.");
jQuery - Remove Elements
                  $("#<id-name>").remove();



jQuery Manipulating CSS
  addClass() - Adds one or more classes to the selected elements
              $("<tag-name>").addClass("<class-name>");


  removeClass() - Removes one or more classes from the selected elements
             $("<tag-name>").removeClass("<class-name>");



  toggleClass() - Toggles between adding/removing classes from the selected elements
              $("<tag-name>").toggleClass("<class-name>");


  css() - Sets or returns the style attribute
             $("<tag-name>").css("background-color","yellow");
jQuery Dimension Methods
jQuery - AJAX


    AJAX = Asynchronous JavaScript and XML.
    In short; AJAX is about loading data in the background and display it on the webpage,
    without reloading the whole page.


jQuery load() Method
     โ—    The jQuery load() method is a simple, but powerful AJAX method.
     โ—    The load() method loads data from a server and puts the returned data into the
          selected element.


Syntax:
              $(selector).load(URL,data,callback);
Example

   ajax load()

          $("#success").load("htmlForm.html", function(response, status, xhr) {
                              if (status == "error") {
                                     var msg = "Sorry but there was an error: ";
                                     $("#error").html(msg + xhr.status + " " + xhr.statusText);
                              }
                         });



   $.ajax()
              $.ajax({
                         url: filename,
                          type: 'GET',
                          dataType: 'html',
                          beforeSend: function() {
                             $('.contentarea').html('<img src="images/loading.gif" />');
                          },
                          success: function(data, textStatus, xhr) {
                             $('.contentarea').html(data);
                          },
                          error: function(xhr, textStatus, errorThrown) {
                             $('.contentarea').html(textStatus);
                          }
                   });
jQuery - AJAX get() and post() Methods


    Two commonly used methods for a request-response between a client and server are:
    GET and POST.


    GET is basically used for just getting (retrieving) some data from the server.
    The GET method may return cached data.


    POST can also be used to get some data from the server. However, the POST
    method NEVER caches data, and is often used to send data along with the request.


Syntax:
             $.get(URL,callback);
             $.post(URL,data,callback);
Introduction of Html/css/js

More Related Content

What's hot

HTML Forms
HTML FormsHTML Forms
HTML Forms
Ravinder Kamboj
ย 
Web Development
Web DevelopmentWeb Development
Web Development
Lena Petsenchuk
ย 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
shreesenthil
ย 
Web Development using HTML & CSS
Web Development using HTML & CSSWeb Development using HTML & CSS
Web Development using HTML & CSS
Brainware Consultancy Pvt Ltd
ย 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
WebStackAcademy
ย 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
Gil Fink
ย 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
ย 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
Eliran Eliassy
ย 
Ajax ppt
Ajax pptAjax ppt
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
Andres Baravalle
ย 
ppt of web development for diploma student
ppt of web development for diploma student ppt of web development for diploma student
ppt of web development for diploma student
Abhishekchauhan863165
ย 
Javascript
JavascriptJavascript
Javascript
mussawir20
ย 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
casestudyhelp
ย 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | Introduction
JohnTaieb
ย 
Css Complete Notes
Css Complete NotesCss Complete Notes
Css Complete Notes
EPAM Systems
ย 
Java script
Java scriptJava script
Java script
reddivarihareesh
ย 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
abhilashagupta
ย 
HTML CSS Basics
HTML CSS BasicsHTML CSS Basics
HTML CSS Basics
Mai Moustafa
ย 
WEB I - 01 - Introduction to Web Development
WEB I - 01 - Introduction to Web DevelopmentWEB I - 01 - Introduction to Web Development
WEB I - 01 - Introduction to Web Development
Randy Connolly
ย 

What's hot (20)

HTML Forms
HTML FormsHTML Forms
HTML Forms
ย 
Web Development
Web DevelopmentWeb Development
Web Development
ย 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
ย 
Web Development using HTML & CSS
Web Development using HTML & CSSWeb Development using HTML & CSS
Web Development using HTML & CSS
ย 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
ย 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
ย 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
ย 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
ย 
Ajax ppt
Ajax pptAjax ppt
Ajax ppt
ย 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
ย 
ppt of web development for diploma student
ppt of web development for diploma student ppt of web development for diploma student
ppt of web development for diploma student
ย 
Javascript
JavascriptJavascript
Javascript
ย 
CSS
CSSCSS
CSS
ย 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
ย 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | Introduction
ย 
Css Complete Notes
Css Complete NotesCss Complete Notes
Css Complete Notes
ย 
Java script
Java scriptJava script
Java script
ย 
cascading style sheet ppt
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
ย 
HTML CSS Basics
HTML CSS BasicsHTML CSS Basics
HTML CSS Basics
ย 
WEB I - 01 - Introduction to Web Development
WEB I - 01 - Introduction to Web DevelopmentWEB I - 01 - Introduction to Web Development
WEB I - 01 - Introduction to Web Development
ย 

Viewers also liked

HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
David Lindkvist
ย 
Html JavaScript and CSS
Html JavaScript and CSSHtml JavaScript and CSS
Html JavaScript and CSSRadhe Krishna Rajan
ย 
HTML5 Bootcamp: Essential HTML, CSS, & JavaScript
HTML5 Bootcamp: Essential HTML, CSS, & JavaScriptHTML5 Bootcamp: Essential HTML, CSS, & JavaScript
HTML5 Bootcamp: Essential HTML, CSS, & JavaScript
Todd Anglin
ย 
HTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery TrainingHTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery Training
ubshreenath
ย 
An Seoโ€™s Intro to Web Dev, HTML, CSS and JavaScript
An Seoโ€™s Intro to Web Dev, HTML, CSS and JavaScriptAn Seoโ€™s Intro to Web Dev, HTML, CSS and JavaScript
An Seoโ€™s Intro to Web Dev, HTML, CSS and JavaScript
Troyfawkes
ย 
Lotus - normas grรกficas
Lotus - normas grรกficasLotus - normas grรกficas
Lotus - normas grรกficas
TT TY
ย 
An Intro to HTML5 and CSS3
An Intro to HTML5 and CSS3An Intro to HTML5 and CSS3
An Intro to HTML5 and CSS3Dhruva Krishnan
ย 
Create Your Tester Portfolio
Create Your Tester PortfolioCreate Your Tester Portfolio
Create Your Tester Portfolio
Shmuel Gershon
ย 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web Design
Dhruva Krishnan
ย 
PHP in one presentation
PHP in one presentationPHP in one presentation
PHP in one presentation
Milad Rahimi
ย 
Threads in PHP - Presentation
Threads in PHP - Presentation Threads in PHP - Presentation
Threads in PHP - Presentation
appserver.io
ย 
PHP
PHPPHP
PHP
Jawhar Ali
ย 
Core Php Component Presentation
Core Php Component PresentationCore Php Component Presentation
Core Php Component Presentation
John Coonen
ย 
Php oop presentation
Php   oop presentationPhp   oop presentation
Php oop presentation
Mutinda Boniface
ย 
PHP presentation - Com 585
PHP presentation - Com 585PHP presentation - Com 585
PHP presentation - Com 585
jstout007
ย 
Devise | Presentation for Alpharetta PHP / Laravel Group
Devise | Presentation for Alpharetta PHP / Laravel GroupDevise | Presentation for Alpharetta PHP / Laravel Group
Devise | Presentation for Alpharetta PHP / Laravel Group
Gary Williams
ย 
PHP presentation
PHP presentationPHP presentation
PHP presentation
Helen Pitlick
ย 
ะŸั€ะตะทะตะฝั‚ะฐั†ะธั ะฝะฐ ั‚ะตะผัƒ "WEB-ะฟั€ะพะณั€ะฐะผะผะธั€ะพะฒะฐะฝะธะต"
ะŸั€ะตะทะตะฝั‚ะฐั†ะธั ะฝะฐ ั‚ะตะผัƒ "WEB-ะฟั€ะพะณั€ะฐะผะผะธั€ะพะฒะฐะฝะธะต"ะŸั€ะตะทะตะฝั‚ะฐั†ะธั ะฝะฐ ั‚ะตะผัƒ "WEB-ะฟั€ะพะณั€ะฐะผะผะธั€ะพะฒะฐะฝะธะต"
ะŸั€ะตะทะตะฝั‚ะฐั†ะธั ะฝะฐ ั‚ะตะผัƒ "WEB-ะฟั€ะพะณั€ะฐะผะผะธั€ะพะฒะฐะฝะธะต"
Gotti Vartanyan
ย 

Viewers also liked (20)

HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
ย 
Html JavaScript and CSS
Html JavaScript and CSSHtml JavaScript and CSS
Html JavaScript and CSS
ย 
HTML5 Bootcamp: Essential HTML, CSS, & JavaScript
HTML5 Bootcamp: Essential HTML, CSS, & JavaScriptHTML5 Bootcamp: Essential HTML, CSS, & JavaScript
HTML5 Bootcamp: Essential HTML, CSS, & JavaScript
ย 
HTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery TrainingHTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery Training
ย 
An Seoโ€™s Intro to Web Dev, HTML, CSS and JavaScript
An Seoโ€™s Intro to Web Dev, HTML, CSS and JavaScriptAn Seoโ€™s Intro to Web Dev, HTML, CSS and JavaScript
An Seoโ€™s Intro to Web Dev, HTML, CSS and JavaScript
ย 
Lotus - normas grรกficas
Lotus - normas grรกficasLotus - normas grรกficas
Lotus - normas grรกficas
ย 
An Intro to HTML5 and CSS3
An Intro to HTML5 and CSS3An Intro to HTML5 and CSS3
An Intro to HTML5 and CSS3
ย 
Create Your Tester Portfolio
Create Your Tester PortfolioCreate Your Tester Portfolio
Create Your Tester Portfolio
ย 
Responsive Web Design
Responsive Web DesignResponsive Web Design
Responsive Web Design
ย 
Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
ย 
Php
PhpPhp
Php
ย 
PHP in one presentation
PHP in one presentationPHP in one presentation
PHP in one presentation
ย 
Threads in PHP - Presentation
Threads in PHP - Presentation Threads in PHP - Presentation
Threads in PHP - Presentation
ย 
PHP
PHPPHP
PHP
ย 
Core Php Component Presentation
Core Php Component PresentationCore Php Component Presentation
Core Php Component Presentation
ย 
Php oop presentation
Php   oop presentationPhp   oop presentation
Php oop presentation
ย 
PHP presentation - Com 585
PHP presentation - Com 585PHP presentation - Com 585
PHP presentation - Com 585
ย 
Devise | Presentation for Alpharetta PHP / Laravel Group
Devise | Presentation for Alpharetta PHP / Laravel GroupDevise | Presentation for Alpharetta PHP / Laravel Group
Devise | Presentation for Alpharetta PHP / Laravel Group
ย 
PHP presentation
PHP presentationPHP presentation
PHP presentation
ย 
ะŸั€ะตะทะตะฝั‚ะฐั†ะธั ะฝะฐ ั‚ะตะผัƒ "WEB-ะฟั€ะพะณั€ะฐะผะผะธั€ะพะฒะฐะฝะธะต"
ะŸั€ะตะทะตะฝั‚ะฐั†ะธั ะฝะฐ ั‚ะตะผัƒ "WEB-ะฟั€ะพะณั€ะฐะผะผะธั€ะพะฒะฐะฝะธะต"ะŸั€ะตะทะตะฝั‚ะฐั†ะธั ะฝะฐ ั‚ะตะผัƒ "WEB-ะฟั€ะพะณั€ะฐะผะผะธั€ะพะฒะฐะฝะธะต"
ะŸั€ะตะทะตะฝั‚ะฐั†ะธั ะฝะฐ ั‚ะตะผัƒ "WEB-ะฟั€ะพะณั€ะฐะผะผะธั€ะพะฒะฐะฝะธะต"
ย 

Similar to Introduction of Html/css/js

Html, css and jquery introduction
Html, css and jquery introductionHtml, css and jquery introduction
Html, css and jquery introduction
cncwebworld
ย 
Overview of PHP and MYSQL
Overview of PHP and MYSQLOverview of PHP and MYSQL
Overview of PHP and MYSQL
Deblina Chowdhury
ย 
Chapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssChapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssTesfaye Yenealem
ย 
Introduction to HTML+CSS+Javascript.pptx
Introduction to HTML+CSS+Javascript.pptxIntroduction to HTML+CSS+Javascript.pptx
Introduction to HTML+CSS+Javascript.pptx
KADAMBARIPUROHIT
ย 
Introduction to HTML+CSS+Javascript.pptx
Introduction to HTML+CSS+Javascript.pptxIntroduction to HTML+CSS+Javascript.pptx
Introduction to HTML+CSS+Javascript.pptx
AliRaza899305
ย 
Web development intership Presentation.pptx
Web development intership Presentation.pptxWeb development intership Presentation.pptx
Web development intership Presentation.pptx
bodepallivamsi1122
ย 
Html advance
Html advanceHtml advance
Html advance
PumoTechnovation
ย 
HTML-Advance.pptx
HTML-Advance.pptxHTML-Advance.pptx
HTML-Advance.pptx
Pandiya Rajan
ย 
Html, CSS, Javascript, Jquery, Meteorๆ‡‰็”จ
Html, CSS, Javascript, Jquery, Meteorๆ‡‰็”จHtml, CSS, Javascript, Jquery, Meteorๆ‡‰็”จ
Html, CSS, Javascript, Jquery, Meteorๆ‡‰็”จ
LearningTech
ย 
wd project.pptx
wd project.pptxwd project.pptx
wd project.pptx
dsffsdf1
ย 
Introduction to Web Development.pptx
Introduction to Web Development.pptxIntroduction to Web Development.pptx
Introduction to Web Development.pptx
Alisha Kamat
ย 
Introduction to Web Development.pptx
Introduction to Web Development.pptxIntroduction to Web Development.pptx
Introduction to Web Development.pptx
GDSCVJTI
ย 
Introduction to Web Development.pptx
Introduction to Web Development.pptxIntroduction to Web Development.pptx
Introduction to Web Development.pptx
Alisha Kamat
ย 
HTML_CSS_JS Workshop
HTML_CSS_JS WorkshopHTML_CSS_JS Workshop
HTML_CSS_JS Workshop
GDSC UofT Mississauga
ย 
Introduction to css by programmerblog.net
Introduction to css by programmerblog.netIntroduction to css by programmerblog.net
Introduction to css by programmerblog.net
Programmer Blog
ย 
Workshop 2 Slides.pptx
Workshop 2 Slides.pptxWorkshop 2 Slides.pptx
Workshop 2 Slides.pptx
DaniyalSardar
ย 
SDP_-_Module_4.ppt
SDP_-_Module_4.pptSDP_-_Module_4.ppt
SDP_-_Module_4.ppt
ssuser568d77
ย 
Introduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and JqueryIntroduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and Jquery
valuebound
ย 
PHP HTML CSS Notes
PHP HTML CSS  NotesPHP HTML CSS  Notes
PHP HTML CSS Notes
Tushar Rajput
ย 
jQuery
jQueryjQuery
jQuery
Vishwa Mohan
ย 

Similar to Introduction of Html/css/js (20)

Html, css and jquery introduction
Html, css and jquery introductionHtml, css and jquery introduction
Html, css and jquery introduction
ย 
Overview of PHP and MYSQL
Overview of PHP and MYSQLOverview of PHP and MYSQL
Overview of PHP and MYSQL
ย 
Chapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssChapter 4a cascade style sheet css
Chapter 4a cascade style sheet css
ย 
Introduction to HTML+CSS+Javascript.pptx
Introduction to HTML+CSS+Javascript.pptxIntroduction to HTML+CSS+Javascript.pptx
Introduction to HTML+CSS+Javascript.pptx
ย 
Introduction to HTML+CSS+Javascript.pptx
Introduction to HTML+CSS+Javascript.pptxIntroduction to HTML+CSS+Javascript.pptx
Introduction to HTML+CSS+Javascript.pptx
ย 
Web development intership Presentation.pptx
Web development intership Presentation.pptxWeb development intership Presentation.pptx
Web development intership Presentation.pptx
ย 
Html advance
Html advanceHtml advance
Html advance
ย 
HTML-Advance.pptx
HTML-Advance.pptxHTML-Advance.pptx
HTML-Advance.pptx
ย 
Html, CSS, Javascript, Jquery, Meteorๆ‡‰็”จ
Html, CSS, Javascript, Jquery, Meteorๆ‡‰็”จHtml, CSS, Javascript, Jquery, Meteorๆ‡‰็”จ
Html, CSS, Javascript, Jquery, Meteorๆ‡‰็”จ
ย 
wd project.pptx
wd project.pptxwd project.pptx
wd project.pptx
ย 
Introduction to Web Development.pptx
Introduction to Web Development.pptxIntroduction to Web Development.pptx
Introduction to Web Development.pptx
ย 
Introduction to Web Development.pptx
Introduction to Web Development.pptxIntroduction to Web Development.pptx
Introduction to Web Development.pptx
ย 
Introduction to Web Development.pptx
Introduction to Web Development.pptxIntroduction to Web Development.pptx
Introduction to Web Development.pptx
ย 
HTML_CSS_JS Workshop
HTML_CSS_JS WorkshopHTML_CSS_JS Workshop
HTML_CSS_JS Workshop
ย 
Introduction to css by programmerblog.net
Introduction to css by programmerblog.netIntroduction to css by programmerblog.net
Introduction to css by programmerblog.net
ย 
Workshop 2 Slides.pptx
Workshop 2 Slides.pptxWorkshop 2 Slides.pptx
Workshop 2 Slides.pptx
ย 
SDP_-_Module_4.ppt
SDP_-_Module_4.pptSDP_-_Module_4.ppt
SDP_-_Module_4.ppt
ย 
Introduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and JqueryIntroduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and Jquery
ย 
PHP HTML CSS Notes
PHP HTML CSS  NotesPHP HTML CSS  Notes
PHP HTML CSS Notes
ย 
jQuery
jQueryjQuery
jQuery
ย 

More from Knoldus Inc.

Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)
Knoldus Inc.
ย 
Secure practices with dot net services.pptx
Secure practices with dot net services.pptxSecure practices with dot net services.pptx
Secure practices with dot net services.pptx
Knoldus Inc.
ย 
Distributed Cache with dot microservices
Distributed Cache with dot microservicesDistributed Cache with dot microservices
Distributed Cache with dot microservices
Knoldus Inc.
ย 
Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)
Knoldus Inc.
ย 
Using InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in JmeterUsing InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in Jmeter
Knoldus Inc.
ย 
Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)
Knoldus Inc.
ย 
Stakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) PresentationStakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) Presentation
Knoldus Inc.
ย 
Introduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) PresentationIntroduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) Presentation
Knoldus Inc.
ย 
Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)
Knoldus Inc.
ย 
Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)
Knoldus Inc.
ย 
Clean Code in Test Automation Differentiating Between the Good and the Bad
Clean Code in Test Automation  Differentiating Between the Good and the BadClean Code in Test Automation  Differentiating Between the Good and the Bad
Clean Code in Test Automation Differentiating Between the Good and the Bad
Knoldus Inc.
ย 
Integrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test AutomationIntegrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test Automation
Knoldus Inc.
ย 
State Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptxState Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptx
Knoldus Inc.
ย 
Authentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptxAuthentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptx
Knoldus Inc.
ย 
OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)
Knoldus Inc.
ย 
Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
Knoldus Inc.
ย 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Knoldus Inc.
ย 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
Knoldus Inc.
ย 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
Knoldus Inc.
ย 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptx
Knoldus Inc.
ย 

More from Knoldus Inc. (20)

Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)
ย 
Secure practices with dot net services.pptx
Secure practices with dot net services.pptxSecure practices with dot net services.pptx
Secure practices with dot net services.pptx
ย 
Distributed Cache with dot microservices
Distributed Cache with dot microservicesDistributed Cache with dot microservices
Distributed Cache with dot microservices
ย 
Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)
ย 
Using InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in JmeterUsing InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in Jmeter
ย 
Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)
ย 
Stakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) PresentationStakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) Presentation
ย 
Introduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) PresentationIntroduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) Presentation
ย 
Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)
ย 
Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)
ย 
Clean Code in Test Automation Differentiating Between the Good and the Bad
Clean Code in Test Automation  Differentiating Between the Good and the BadClean Code in Test Automation  Differentiating Between the Good and the Bad
Clean Code in Test Automation Differentiating Between the Good and the Bad
ย 
Integrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test AutomationIntegrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test Automation
ย 
State Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptxState Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptx
ย 
Authentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptxAuthentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptx
ย 
OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)
ย 
Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
ย 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
ย 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
ย 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
ย 
Introduction to Redis and its features.pptx
Introduction to Redis and its features.pptxIntroduction to Redis and its features.pptx
Introduction to Redis and its features.pptx
ย 

Introduction of Html/css/js

  • 1. Introduction of HTML/CSS/JS Ruchi Agarwal Software Consultant Knoldus Software
  • 2. What is HTML? โ— HTML is a language for describing web pages. โ— HTML stands for Hyper Text Markup Language โ— HTML is a markup language โ— A markup language is a set of markup tags โ— The tags describe document content โ— HTML documents contain HTML tags and plain text โ— HTML documents are also called web pages
  • 3. HTML Tags โ— HTML markup tags are usually called HTML tags โ— HTML tags are keywords (tag names) surrounded by angle brackets like <html> โ— HTML tags normally come in pairs like <b> and </b> โ— The first tag in a pair is the start tag, the second tag is the end tag โ— The end tag is written like the start tag, with a forward slash before the tag name โ— Start and end tags are also called opening tags and closing tags <tagname>content</tagname>
  • 4. Basic HTML page structure
  • 6. What is CSS? โ— CSS stands for Cascading Style Sheets โ— Styles define how to display HTML elements โ— Styles were added to HTML 4.0 to solve a problem โ— External Style Sheets can save a lot of work โ— External Style Sheets are stored in CSS files โ— A CSS (cascading style sheet) file allows to separate web sites HTML content from itโ€™s style.
  • 7. How to use CSS? There are three ways of inserting a style sheet: External Style Sheet: An external style sheet is ideal when the style is applied to many pages. <head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head> Internal Style Sheet: An internal style sheet should be used when a single document has a unique style. <head> <style> p {margin-left:20px;} body {background-image:url("images/back40.gif");} </style> </head>
  • 8. Inline Styles: To use inline styles use the style attribute in the relevant tag. The style attribute can contain any CSS property. <p style="color:#fafafa;margin-left:20px">This is a paragraph.</p> Multiple Styles Will Cascade into One: Cascading order โ— Inline style (inside an HTML element) โ— Internal style sheet (in the head section) โ— External style sheet โ— Browser default
  • 9. CSS Syntax A CSS rule has two main parts: a selector, and one or more declarations: Combining Selectors h1, h2, h3, h4, h5, h6 { color: #009900; font-family: Georgia, sans-serif; }
  • 10. The id Selector The id selector is used to specify a style for a single, unique element. The id selector uses the id attribute of the HTML element, and is defined with a "#". Syntax #selector-id { property : value ; } The class Selector The class selector is used to specify a style for a group of elements. The class selector uses the HTML class attribute, and is defined with a "." Syntax .selector-class { property : value ; }
  • 11. CSS Anchors, Links and Pseudo Classes: Below are the various ways you can use CSS to style links. a:link {color: #009900;} a:visited {color: #999999;} a:hover {color: #333333;} a:focus {color: #333333;} a:active {color: #009900;}
  • 12. The CSS Box Model โ— All HTML elements can be considered as boxes. In CSS, the term "box model" is used when talking about design and layout. โ— The CSS box model is essentially a box that wraps around HTML elements, and it consists of: margins, borders, padding, and the actual content. โ— The box model allows to place a border around elements and space elements in relation to other elements.
  • 13. Example #signup-form { #signup-form .fieldgroup input, #signup-form background-color: #F8FDEF; .fieldgroup textarea, #signup-form border: 1px solid #DFDCDC; .fieldgroup select { border-radius: 15px 15px 15px 15px; float: right; display: inline-block; margin: 10px 0; margin-bottom: 30px; height: 25px; margin-left: 20px; } margin-top: 10px; padding: 25px 50px 10px; #signup-form .submit { width: 350px; padding: 10px; } width: 220px; height: 40px !important; #signup-form .fieldgroup { } display: inline-block; padding: 8px 10px; #signup-form .fieldgroup label.error { width: 340px; color: #FB3A3A; } display: inline-block; margin: 4px 0 5px 125px; #signup-form .fieldgroup label { padding: 0; float: left; text-align: left; padding: 15px 0 0; width: 220px; text-align: right; } width: 110px; }
  • 14. What is JavaScript โ— JavaScript is a Scripting Language โ— A scripting language is a lightweight programming language. โ— JavaScript is programming code that can be inserted into HTML pages. โ— JavaScript inserted into HTML pages, can be executed by all modern web browsers.
  • 15. How to use JavaScript? The <script> Tag To insert a JavaScript into an HTML page, use the <script> tag. The <script> and </script> tells where the JavaScript starts and ends. <script> alert("My First JavaScript"); </script> JavaScript in <body> <html> <body> <script> document.write("<h1>This is a heading</h1>"); </script> </body> </html>
  • 16. External JavaScripts Scripts can also be placed in external files. External files often contain code to be used by several different web pages. External JavaScript files have the file extension .js. To use an external script, point to the .js file in the "src" attribute of the <script> tag: <html> <body> <script src="myScript.js"></script> </body> </html>
  • 17. The HTML DOM (Document Object Model) When a web page is loaded, the browser creates a Document Object Model of the page. The HTML DOM model is constructed as a tree of Objects:
  • 18. Finding HTML Elements by Id document.getElementById("<id-name>"); Finding HTML Elements by Tag Name document.getElementsByTagName("<tag>"); Finding HTML Elements by Name document.getElementsByName(โ€œ<name-attr>โ€) Finding HTML Elements by Class document.getElementByClass(โ€œ<class-name>โ€)
  • 19. Writing Into HTML Output document.write("<h1>This is a heading</h1>"); document.write("<p>This is a paragraph</p>"); Reacting to Events <button type="button" onclick="alert('Welcome!')">Click Me!</button> Changing HTML Content Using JavaScript to manipulate the content of HTML elements is a very powerful functionality. x=document.getElementById("demo") //Find the element x.innerHTML="Hello JavaScript"; //Change the content
  • 20. Changing HTML Styles Changing the style of an HTML element, is a variant of changing an HTML attribute. x=document.getElementById("demo") //Find the element x.style.color="#ff0000"; //Change the style Validate Input JavaScript is commonly used to validate input. if isNaN(x) {alert("Not Numeric")};
  • 21. Example function validateForm() { var nameValue=document.getElementById('name'); verifyName(nameValue); var emailValue=document.getElementById('email'); verifyEmail(emailValue); var password=document.getElementById('password'); verifyPassword(password,8,12); } function verifyName(uname) { var letters = /^[A-Za-z]+$/; if(uname.value.match(letters)) { return true; } else { alert('Invalid name'); return false; } }
  • 22. What is jQuery? โ— jQuery is a lightweight, "write less, do more", JavaScript library. โ— The purpose of jQuery is to make it much easier to use JavaScript on your website. โ— jQuery takes a lot of common tasks that requires many lines of JavaScript code to accomplish, and wraps it into methods that you can call with a single line of code. โ— jQuery also simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation. Features: โ— HTML/DOM manipulation โ— CSS manipulation โ— HTML event methods โ— Effects and animations โ— AJAX
  • 23. jQuery Syntax Basic syntax: $(selector).action() โ— A $ sign to define/access jQuery โ— A (selector) to "query (or find)" HTML elements โ— A jQuery action() to be performed on the element(s) Example: $("p").hide() - hides all <p> elements. How to use Jquery: <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> </head>
  • 24. jQuery Selectors: jQuery selectors allow you to select and manipulate HTML element(s). The element , id and class Selector The jQuery element selector selects elements based on their tag names. $("<tag-name>") //element selector $("#<id-name>") // id selector $(".<class-name>") // class selector Example $(document).ready(function(){ $("button").click(function(){ $("p").hide(); $("#test").hide(); //#id selector $(".test").hide(); //.class selector }); });
  • 26. jQuery Event All the different visitors actions that a web page can respond to are called events. An event represents the precise moment when something happens. Mouse Events Keyboard Events Form Events Document/Window Events click keypress submit load dblclick keydown change resize mouseenter keyup focus scroll mouseleave blur unload Example: $("p").click(function(){ // action goes here!! });
  • 27. JQuery Effects: JQuery hide(), show() and toggle() method $(selector).hide(speed,callback); $(selector).show(speed,callback); $(selector).toggle(speed,callback); jQuery fadeIn() , fadeOut() ,fadeToggle() and fadeTo() method $(selector).fadeIn(speed,callback); $(selector).fadeOut(speed,callback); $(selector).fadeToggle(speed,callback); $(selector).fadeTo(speed,callback);
  • 28. jQuery Sliding Methods $(selector).slideDown(speed,callback); $(selector).slideUp(speed,callback); $(selector).slideToggle(speed,callback); jQuery Animations - The animate() Method $(selector).animate({params},speed,callback); jQuery stop() Method $(selector).stop(stopAll,goToEnd);
  • 29. jQuery Method Chaining $(selector).css("color","red").slideUp(2000).slideDown(2000); jQuery - Get Content and Attributes $(selector).click(function(){ alert("Text: " + $(selector).text()); alert("HTML: " + $(selector).html()); alert("Value: " + $(input-selector).val()); alert($(link-selector).attr("href")); });
  • 30. jQuery - Set Content and Attributes $(selector).click(function(){ $(selector).text("Hello world!"); $(selector).html("<b>Hello world!</b>"); $(input-selector).val("Dolly Duck"); $(link-selector).attr("href","http://www.google.comโ€); }); jQuery - Add Elements $(selector).append("Some appended text."); $(selector).prepend("Some prepended text.");
  • 31. jQuery - Remove Elements $("#<id-name>").remove(); jQuery Manipulating CSS addClass() - Adds one or more classes to the selected elements $("<tag-name>").addClass("<class-name>"); removeClass() - Removes one or more classes from the selected elements $("<tag-name>").removeClass("<class-name>"); toggleClass() - Toggles between adding/removing classes from the selected elements $("<tag-name>").toggleClass("<class-name>"); css() - Sets or returns the style attribute $("<tag-name>").css("background-color","yellow");
  • 33. jQuery - AJAX AJAX = Asynchronous JavaScript and XML. In short; AJAX is about loading data in the background and display it on the webpage, without reloading the whole page. jQuery load() Method โ— The jQuery load() method is a simple, but powerful AJAX method. โ— The load() method loads data from a server and puts the returned data into the selected element. Syntax: $(selector).load(URL,data,callback);
  • 34. Example ajax load() $("#success").load("htmlForm.html", function(response, status, xhr) { if (status == "error") { var msg = "Sorry but there was an error: "; $("#error").html(msg + xhr.status + " " + xhr.statusText); } }); $.ajax() $.ajax({ url: filename, type: 'GET', dataType: 'html', beforeSend: function() { $('.contentarea').html('<img src="images/loading.gif" />'); }, success: function(data, textStatus, xhr) { $('.contentarea').html(data); }, error: function(xhr, textStatus, errorThrown) { $('.contentarea').html(textStatus); } });
  • 35. jQuery - AJAX get() and post() Methods Two commonly used methods for a request-response between a client and server are: GET and POST. GET is basically used for just getting (retrieving) some data from the server. The GET method may return cached data. POST can also be used to get some data from the server. However, the POST method NEVER caches data, and is often used to send data along with the request. Syntax: $.get(URL,callback); $.post(URL,data,callback);