SlideShare a Scribd company logo
1 of 43
Download to read offline
 jQuery is a fast, small, and feature-rich JavaScript
library
 It is used for
 HTML document traversal and manipulation
 event handling
 animation
 Ajax
 With a combination of versatility and extensibility,
jQuery has changed the way that millions of people
write JavaScript.
 jQuery is cross-browser
 jQuery is more easy to use than raw
javascript
 jQuery is extensible
 jQuery is simplifies and has rich AJAX support
 jQuery has large development community
and many plugins
 Excellent documentation
 Download jQuery from www.jquery.com
 Reference or link the same in your application
just like external javascript file.

JavaScript jQuery
Type Programming Language API (Application
Programming Interface)
Language Written in C. Interpreted
Language.
Uses resources given by
JavaScript to make things
easier.
Simplicity One need to write entire code
from scratch which is time
consuming.
No need to write all code,
scripts are already
available.
Compatibility Need to handle multi-browser
compatibility.
It is cross-browser. No
need to handle
compatibility.
Length of Code Need to write more code. Code is less than
javascript.
Light/Heavy Weight Heavy weight compare to
jQuery.
Lightweight
jQuery syntax is made by using HTML elements
selector and perform some action on the
elements are manipulation in Dot sign(.).
 $ sign define the jQuery.
 A (selector) defines the Query element's to
find in HTML element's.
 And action() to be performed on the
element's.
 $(document).ready is a jQuery event
 It fires when DOM is fully loaded and ready to
be manipulated by script
 Earliest process of page load process
 Script can safely access the elements of html
DOM
 This events fires before all images, css etc.
are fully loaded
 jQuery selectors is most important aspects of
the jQuery library.
 jQuery selector allow you to select and
manipulate elements
 Selectors are useful and required at every
step while using jQuery.
Selector Description
element Selector Selects all element match of given elements.
this Selector Selects current elements.
#id Selector Selects element whose id is match of given elements.
.class Selector Selects element whose class is match of given elements.
* Selects all elements in the document.
 To select the element by html tag name we use
Element Selector
 Syntax $(element_name)
$(‘td’) : Selects all td elements
$(‘div a’) : Select all anchor elements
that are descendants of div
$(‘div, span, a’) : select all div, span
and anchor elements
 To select td tag and count total number of td
tags in document
 Select all tr tag and change its back-ground
color
 To select the current HTML element we use
this Selector
 Syntax $(‘this’)
 #id selector is most efficient selector among all jQuery
selectors
 If you know the id of an element you want to select,
always use #id selector
 HTML id is always unique on the page. jQuery #id selector
returns only first element if you have more than one
selector with name on single page.
 jQuery doesn’t return any error when element with
particular id not found unlike javascript.
 Syntax $(#element id)
This will change the background colour of
button with id button1.
 To select the element by their css class name class
Selector is used
 Class Selector uses JavaScript getElementByClassName()
 Syntax $( ‘.class-name’ )
$(‘.small’) : Selects all elements with class
small
$(‘.small, .big’) : Select all elements with
class small or big
$(‘div.small, .big’) : Select div elements with
class small and any element with class big
 Select all elements with class small and set its
border to 5px with red colour
 To select the element by their attribute or attribute with
specific value attribute selector is used
 Syntax $( ‘[attribute]’ )
$( ‘[attribute=“value”]’ )
$(‘[title]’) : Selects all elements having
title attribute
$(‘div [title]’) : Select all elements having
title attribute
$(‘[title]=“tt1’) : Select all elements that
have title attribute value - tt1
$(‘div [title]=“tt1’) : Select all div elements
that have title attribute value - tt1
 Select all elements having title attribute and
set its border to 5px with red colour
 * selector will select all the elements of DOM
 All the user action to which a web page can
respond to are known as event
 Some common actions are
 Click
 Double click
 Hover
 Key press
 When event occurred a Event Handler is
called
 Using bind()
$(selector).bind(eventType,eventData,handlerFunct
ion)
eventType: JavaScript event like click, hover etc.
eventData: Any data that you want to pass to
event handler function when event
fired(triggered)
handlerFunction: the operation to be performed
each time event is fired
 Using event method directly()
$(selector).eventType(handlerFunction)
$(selector).click(handlerFunction)
$(selector).hover(handlerFunction)
 Removing event
$(selector).unbind(eventType, handlerFunction)
 The jQuery library provides several
techniques for adding animation to a web
page.
 These include simple, standard animations
that are frequently used, and the ability to
craft sophisticated custom effects.
animate() Runs a custom animation on the selected elements
fadeIn() Fades in the selected elements
fadeOut() Fades out the selected elements
fadeTo() Fades in/out the selected elements to a given opacity
fadeToggle() Toggles between the fadeIn() and fadeOut() methods
hide() Hides the selected elements
show() Shows the selected elements
slideDown() Slides-down (shows) the selected elements
slideToggle() Toggles between the slideUp() and slideDown() methods
 The jQuery animate() allows us to animate CSS
properties
$(selector).animate(properties,[duration],[easing],[compl
ete])
Properties: CSS Properties
Duration: Duration of animation in milliseconds.
Default is 400.
Easing: Used for transition. Default is swing.
Complete: A function to call once animation is
complete.
 One very important part of jQuery is the
possibility to manipulate the DOM.
 jQuery has DOM related methods that is used
to to access and manipulate elements and
attributes.
 A few of these methods are text(), html(), attr(),
and val()
 The jQuery text() method is either used to get
the combined text contents of the selected
elements, including their descendants, or set
the text contents of the selected elements.
Syntax:
$(selector).text() ; // for get content
$(selector).text(new text); //for set content
Example
 The jQuery html() method is used to get or set
the HTML contents of the elements.
Syntax:
$(selector).html() ; // for get html
$(selector).html(html _code); //for set html
Example
 The jQuery val() method is used to get or set
the current value of the HTML form elements
such as <input>, <select> and <textarea>.
Syntax:
$(selector).val() ; // to get value
$(selector).val(newVal); //for set new value
Example
 jQuery attr() method to either get the value of an
element's attribute or set one or more attributes
for the selected element.
Syntax:
$(selector).attr() ; // to get value
$(selector).attr({“attribute1”:”attribute value1”,
“attribute2”:”attribute value2”…}); //for set new
value
 jQuery provides several methods, such as
addClass(), removeClass(), toggleClass() etc. to
manipulate the CSS classes assigned to
HTML elements.
 jQuery addClass() method adds one or more
classes to the selected elements.
Syntax:
$(selector).addClass(“class1 class2….”) ;
 The jQuery removeClass() method used to remove
the classes from the elements
 Using removeClass() method can remove a single
class, multiple classes, or all classes at once from
the selected elements.
Syntax:
$(selector).removeClass(“class”) ; // remove single class
$(selector).removeClass(“class1 class2”) ; // remove
multiple class
$(selector).removeClass() ; // remove all classes at once
 The jQuery toggleClass() add or remove one or
more classes from the selected elements
 If the selected element already has the class,
then it is removed; if an element does not
have the class, then it is added
Syntax:
$(selector).toggleClass(“class1 class2…”) ; //Toggle
one or more class
 jQuery provides several methods, like
append(), prepend(),before(), after() etc. that
allows us to insert new content inside an
existing element.
 jQuery provides two methods, such as
empty(), remove(), to remove existing HTML
elements or contents from the document.
 append()
 jQuery append() method is used to insert content to the end
of the selected elements.
 prepend()
 The prepend() method is used to insert content to the
beginning of the selected elements.
 before()
 The jQuery before() method is used to insert content before
the selected elements.
 after()
 The jQuery after() method is used to insert content after the
selected elements.
 empty()
 jQuery empty() method removes all child elements as
well as other descendant elements and the text content
within the selected elements from the DOM.
 remove()
 The jQuery remove() method removes the selected
elements from the DOM as well as everything inside it.
 In addition to the elements themselves, all bound events
and jQuery data associated with the elements are
removed.

More Related Content

Similar to Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf

How to increase Performance of Web Application using JQuery
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 JQuerykolkatageeks
 
Web technologies-course 11.pptx
Web technologies-course 11.pptxWeb technologies-course 11.pptx
Web technologies-course 11.pptxStefan Oprea
 
jQuery - Tips And Tricks
jQuery - Tips And TricksjQuery - Tips And Tricks
jQuery - Tips And TricksLester Lievens
 
J Query Introduction And JQuery Selectors
J Query Introduction And JQuery SelectorsJ Query Introduction And JQuery Selectors
J Query Introduction And JQuery SelectorsAnand Kumar Rajana
 
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...Edureka!
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQueryGunjan Kumar
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQueryLaila Buncab
 
jQuery basics for Beginners
jQuery basics for BeginnersjQuery basics for Beginners
jQuery basics for BeginnersPooja Saxena
 
Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQueryKnoldus Inc.
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object ModelWebStackAcademy
 
Web Design & Development - Session 6
Web Design & Development - Session 6Web Design & Development - Session 6
Web Design & Development - Session 6Shahrzad Peyman
 
Global Attributes Window Event Attributes Form Events Ujjwal matoliya.pptx
Global Attributes Window Event Attributes Form Events Ujjwal matoliya.pptxGlobal Attributes Window Event Attributes Form Events Ujjwal matoliya.pptx
Global Attributes Window Event Attributes Form Events Ujjwal matoliya.pptxujjwalmatoliya
 

Similar to Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf (20)

How to increase Performance of Web Application using JQuery
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
 
Jquery
JqueryJquery
Jquery
 
jQuery
jQueryjQuery
jQuery
 
Web technologies-course 11.pptx
Web technologies-course 11.pptxWeb technologies-course 11.pptx
Web technologies-course 11.pptx
 
jQuery - Tips And Tricks
jQuery - Tips And TricksjQuery - Tips And Tricks
jQuery - Tips And Tricks
 
J Query Introduction And JQuery Selectors
J Query Introduction And JQuery SelectorsJ Query Introduction And JQuery Selectors
J Query Introduction And JQuery Selectors
 
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
jQuery Tutorial For Beginners | Developing User Interface (UI) Using jQuery |...
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
 
jQuery basics for Beginners
jQuery basics for BeginnersjQuery basics for Beginners
jQuery basics for Beginners
 
Jquery library
Jquery libraryJquery library
Jquery library
 
jQuery
jQueryjQuery
jQuery
 
Jquery- One slide completing all JQuery
Jquery- One slide completing all JQueryJquery- One slide completing all JQuery
Jquery- One slide completing all JQuery
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to Jquery
 
JQuery
JQueryJQuery
JQuery
 
Jquery
JqueryJquery
Jquery
 
Web Design & Development - Session 6
Web Design & Development - Session 6Web Design & Development - Session 6
Web Design & Development - Session 6
 
Jquery Basics
Jquery BasicsJquery Basics
Jquery Basics
 
Global Attributes Window Event Attributes Form Events Ujjwal matoliya.pptx
Global Attributes Window Event Attributes Form Events Ujjwal matoliya.pptxGlobal Attributes Window Event Attributes Form Events Ujjwal matoliya.pptx
Global Attributes Window Event Attributes Form Events Ujjwal matoliya.pptx
 

More from RAVALCHIRAG1

SE_Unit 3_System & Requirement Engineering.pdf
SE_Unit 3_System & Requirement Engineering.pdfSE_Unit 3_System & Requirement Engineering.pdf
SE_Unit 3_System & Requirement Engineering.pdfRAVALCHIRAG1
 
SE_Unit 5_DE & Testing.pdf computer networks technology
SE_Unit 5_DE & Testing.pdf computer networks technologySE_Unit 5_DE & Testing.pdf computer networks technology
SE_Unit 5_DE & Testing.pdf computer networks technologyRAVALCHIRAG1
 
SE_Unit 2.pdf it is a process model of it student
SE_Unit 2.pdf it is a process model of it studentSE_Unit 2.pdf it is a process model of it student
SE_Unit 2.pdf it is a process model of it studentRAVALCHIRAG1
 
LONAVALA TRIP.pdf it is a collage tour lonavala
LONAVALA  TRIP.pdf it is a collage tour lonavalaLONAVALA  TRIP.pdf it is a collage tour lonavala
LONAVALA TRIP.pdf it is a collage tour lonavalaRAVALCHIRAG1
 
SQA_Unit 3.pdf it is a database education
SQA_Unit 3.pdf it is a database educationSQA_Unit 3.pdf it is a database education
SQA_Unit 3.pdf it is a database educationRAVALCHIRAG1
 
TT Version 3.0.pdf
TT Version 3.0.pdfTT Version 3.0.pdf
TT Version 3.0.pdfRAVALCHIRAG1
 
QuestionBankUnit2,4,5.docx
QuestionBankUnit2,4,5.docxQuestionBankUnit2,4,5.docx
QuestionBankUnit2,4,5.docxRAVALCHIRAG1
 
Fire ppt_final_siddh.ppt
Fire ppt_final_siddh.pptFire ppt_final_siddh.ppt
Fire ppt_final_siddh.pptRAVALCHIRAG1
 
Fire ppt_final_siddh.ppt
Fire ppt_final_siddh.pptFire ppt_final_siddh.ppt
Fire ppt_final_siddh.pptRAVALCHIRAG1
 
Earthquake ppt.pptx [Repaired].pptx
Earthquake ppt.pptx [Repaired].pptxEarthquake ppt.pptx [Repaired].pptx
Earthquake ppt.pptx [Repaired].pptxRAVALCHIRAG1
 

More from RAVALCHIRAG1 (13)

SE_Unit 3_System & Requirement Engineering.pdf
SE_Unit 3_System & Requirement Engineering.pdfSE_Unit 3_System & Requirement Engineering.pdf
SE_Unit 3_System & Requirement Engineering.pdf
 
SE_Unit 5_DE & Testing.pdf computer networks technology
SE_Unit 5_DE & Testing.pdf computer networks technologySE_Unit 5_DE & Testing.pdf computer networks technology
SE_Unit 5_DE & Testing.pdf computer networks technology
 
SE_Unit 2.pdf it is a process model of it student
SE_Unit 2.pdf it is a process model of it studentSE_Unit 2.pdf it is a process model of it student
SE_Unit 2.pdf it is a process model of it student
 
LONAVALA TRIP.pdf it is a collage tour lonavala
LONAVALA  TRIP.pdf it is a collage tour lonavalaLONAVALA  TRIP.pdf it is a collage tour lonavala
LONAVALA TRIP.pdf it is a collage tour lonavala
 
SQA_Unit 3.pdf it is a database education
SQA_Unit 3.pdf it is a database educationSQA_Unit 3.pdf it is a database education
SQA_Unit 3.pdf it is a database education
 
TT Version 3.0.pdf
TT Version 3.0.pdfTT Version 3.0.pdf
TT Version 3.0.pdf
 
QuestionBankUnit2,4,5.docx
QuestionBankUnit2,4,5.docxQuestionBankUnit2,4,5.docx
QuestionBankUnit2,4,5.docx
 
Fire ppt_final_siddh.ppt
Fire ppt_final_siddh.pptFire ppt_final_siddh.ppt
Fire ppt_final_siddh.ppt
 
Fire ppt_final_siddh.ppt
Fire ppt_final_siddh.pptFire ppt_final_siddh.ppt
Fire ppt_final_siddh.ppt
 
EDM_UNIT 2-1.ppt
EDM_UNIT 2-1.pptEDM_UNIT 2-1.ppt
EDM_UNIT 2-1.ppt
 
Earthquake ppt.pptx [Repaired].pptx
Earthquake ppt.pptx [Repaired].pptxEarthquake ppt.pptx [Repaired].pptx
Earthquake ppt.pptx [Repaired].pptx
 
EDM 2
EDM 2EDM 2
EDM 2
 
EDM_UNIT 1.ppt
EDM_UNIT 1.pptEDM_UNIT 1.ppt
EDM_UNIT 1.ppt
 

Recently uploaded

Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Data Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxData Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxFurkanTasci3
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
Data Science Project: Advancements in Fetal Health Classification
Data Science Project: Advancements in Fetal Health ClassificationData Science Project: Advancements in Fetal Health Classification
Data Science Project: Advancements in Fetal Health ClassificationBoston Institute of Analytics
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSAishani27
 
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Servicejennyeacort
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Data Warehouse , Data Cube Computation
Data Warehouse   , Data Cube ComputationData Warehouse   , Data Cube Computation
Data Warehouse , Data Cube Computationsit20ad004
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...Suhani Kapoor
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 

Recently uploaded (20)

Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
Russian Call Girls Dwarka Sector 15 💓 Delhi 9999965857 @Sabina Modi VVIP MODE...
Russian Call Girls Dwarka Sector 15 💓 Delhi 9999965857 @Sabina Modi VVIP MODE...Russian Call Girls Dwarka Sector 15 💓 Delhi 9999965857 @Sabina Modi VVIP MODE...
Russian Call Girls Dwarka Sector 15 💓 Delhi 9999965857 @Sabina Modi VVIP MODE...
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Data Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptxData Science Jobs and Salaries Analysis.pptx
Data Science Jobs and Salaries Analysis.pptx
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
Data Science Project: Advancements in Fetal Health Classification
Data Science Project: Advancements in Fetal Health ClassificationData Science Project: Advancements in Fetal Health Classification
Data Science Project: Advancements in Fetal Health Classification
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
Ukraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICSUkraine War presentation: KNOW THE BASICS
Ukraine War presentation: KNOW THE BASICS
 
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
Call Girls In Noida City Center Metro 24/7✡️9711147426✡️ Escorts Service
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Data Warehouse , Data Cube Computation
Data Warehouse   , Data Cube ComputationData Warehouse   , Data Cube Computation
Data Warehouse , Data Cube Computation
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 

Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf

  • 1.
  • 2.  jQuery is a fast, small, and feature-rich JavaScript library  It is used for  HTML document traversal and manipulation  event handling  animation  Ajax  With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.
  • 3.  jQuery is cross-browser  jQuery is more easy to use than raw javascript  jQuery is extensible  jQuery is simplifies and has rich AJAX support  jQuery has large development community and many plugins  Excellent documentation
  • 4.  Download jQuery from www.jquery.com  Reference or link the same in your application just like external javascript file. 
  • 5. JavaScript jQuery Type Programming Language API (Application Programming Interface) Language Written in C. Interpreted Language. Uses resources given by JavaScript to make things easier. Simplicity One need to write entire code from scratch which is time consuming. No need to write all code, scripts are already available. Compatibility Need to handle multi-browser compatibility. It is cross-browser. No need to handle compatibility. Length of Code Need to write more code. Code is less than javascript. Light/Heavy Weight Heavy weight compare to jQuery. Lightweight
  • 6. jQuery syntax is made by using HTML elements selector and perform some action on the elements are manipulation in Dot sign(.).  $ sign define the jQuery.  A (selector) defines the Query element's to find in HTML element's.  And action() to be performed on the element's.
  • 7.  $(document).ready is a jQuery event  It fires when DOM is fully loaded and ready to be manipulated by script  Earliest process of page load process  Script can safely access the elements of html DOM  This events fires before all images, css etc. are fully loaded
  • 8.
  • 9.  jQuery selectors is most important aspects of the jQuery library.  jQuery selector allow you to select and manipulate elements  Selectors are useful and required at every step while using jQuery.
  • 10. Selector Description element Selector Selects all element match of given elements. this Selector Selects current elements. #id Selector Selects element whose id is match of given elements. .class Selector Selects element whose class is match of given elements. * Selects all elements in the document.
  • 11.  To select the element by html tag name we use Element Selector  Syntax $(element_name) $(‘td’) : Selects all td elements $(‘div a’) : Select all anchor elements that are descendants of div $(‘div, span, a’) : select all div, span and anchor elements
  • 12.  To select td tag and count total number of td tags in document  Select all tr tag and change its back-ground color
  • 13.  To select the current HTML element we use this Selector  Syntax $(‘this’)
  • 14.  #id selector is most efficient selector among all jQuery selectors  If you know the id of an element you want to select, always use #id selector  HTML id is always unique on the page. jQuery #id selector returns only first element if you have more than one selector with name on single page.  jQuery doesn’t return any error when element with particular id not found unlike javascript.  Syntax $(#element id)
  • 15. This will change the background colour of button with id button1.
  • 16.  To select the element by their css class name class Selector is used  Class Selector uses JavaScript getElementByClassName()  Syntax $( ‘.class-name’ ) $(‘.small’) : Selects all elements with class small $(‘.small, .big’) : Select all elements with class small or big $(‘div.small, .big’) : Select div elements with class small and any element with class big
  • 17.  Select all elements with class small and set its border to 5px with red colour
  • 18.  To select the element by their attribute or attribute with specific value attribute selector is used  Syntax $( ‘[attribute]’ ) $( ‘[attribute=“value”]’ ) $(‘[title]’) : Selects all elements having title attribute $(‘div [title]’) : Select all elements having title attribute $(‘[title]=“tt1’) : Select all elements that have title attribute value - tt1 $(‘div [title]=“tt1’) : Select all div elements that have title attribute value - tt1
  • 19.  Select all elements having title attribute and set its border to 5px with red colour
  • 20.  * selector will select all the elements of DOM
  • 21.  All the user action to which a web page can respond to are known as event  Some common actions are  Click  Double click  Hover  Key press  When event occurred a Event Handler is called
  • 22.  Using bind() $(selector).bind(eventType,eventData,handlerFunct ion) eventType: JavaScript event like click, hover etc. eventData: Any data that you want to pass to event handler function when event fired(triggered) handlerFunction: the operation to be performed each time event is fired
  • 23.  Using event method directly() $(selector).eventType(handlerFunction) $(selector).click(handlerFunction) $(selector).hover(handlerFunction)  Removing event $(selector).unbind(eventType, handlerFunction)
  • 24.  The jQuery library provides several techniques for adding animation to a web page.  These include simple, standard animations that are frequently used, and the ability to craft sophisticated custom effects.
  • 25. animate() Runs a custom animation on the selected elements fadeIn() Fades in the selected elements fadeOut() Fades out the selected elements fadeTo() Fades in/out the selected elements to a given opacity fadeToggle() Toggles between the fadeIn() and fadeOut() methods hide() Hides the selected elements
  • 26. show() Shows the selected elements slideDown() Slides-down (shows) the selected elements slideToggle() Toggles between the slideUp() and slideDown() methods
  • 27.  The jQuery animate() allows us to animate CSS properties $(selector).animate(properties,[duration],[easing],[compl ete]) Properties: CSS Properties Duration: Duration of animation in milliseconds. Default is 400. Easing: Used for transition. Default is swing. Complete: A function to call once animation is complete.
  • 28.
  • 29.  One very important part of jQuery is the possibility to manipulate the DOM.  jQuery has DOM related methods that is used to to access and manipulate elements and attributes.  A few of these methods are text(), html(), attr(), and val()
  • 30.  The jQuery text() method is either used to get the combined text contents of the selected elements, including their descendants, or set the text contents of the selected elements. Syntax: $(selector).text() ; // for get content $(selector).text(new text); //for set content
  • 32.  The jQuery html() method is used to get or set the HTML contents of the elements. Syntax: $(selector).html() ; // for get html $(selector).html(html _code); //for set html
  • 34.  The jQuery val() method is used to get or set the current value of the HTML form elements such as <input>, <select> and <textarea>. Syntax: $(selector).val() ; // to get value $(selector).val(newVal); //for set new value
  • 36.  jQuery attr() method to either get the value of an element's attribute or set one or more attributes for the selected element. Syntax: $(selector).attr() ; // to get value $(selector).attr({“attribute1”:”attribute value1”, “attribute2”:”attribute value2”…}); //for set new value
  • 37.  jQuery provides several methods, such as addClass(), removeClass(), toggleClass() etc. to manipulate the CSS classes assigned to HTML elements.
  • 38.  jQuery addClass() method adds one or more classes to the selected elements. Syntax: $(selector).addClass(“class1 class2….”) ;
  • 39.  The jQuery removeClass() method used to remove the classes from the elements  Using removeClass() method can remove a single class, multiple classes, or all classes at once from the selected elements. Syntax: $(selector).removeClass(“class”) ; // remove single class $(selector).removeClass(“class1 class2”) ; // remove multiple class $(selector).removeClass() ; // remove all classes at once
  • 40.  The jQuery toggleClass() add or remove one or more classes from the selected elements  If the selected element already has the class, then it is removed; if an element does not have the class, then it is added Syntax: $(selector).toggleClass(“class1 class2…”) ; //Toggle one or more class
  • 41.  jQuery provides several methods, like append(), prepend(),before(), after() etc. that allows us to insert new content inside an existing element.  jQuery provides two methods, such as empty(), remove(), to remove existing HTML elements or contents from the document.
  • 42.  append()  jQuery append() method is used to insert content to the end of the selected elements.  prepend()  The prepend() method is used to insert content to the beginning of the selected elements.  before()  The jQuery before() method is used to insert content before the selected elements.  after()  The jQuery after() method is used to insert content after the selected elements.
  • 43.  empty()  jQuery empty() method removes all child elements as well as other descendant elements and the text content within the selected elements from the DOM.  remove()  The jQuery remove() method removes the selected elements from the DOM as well as everything inside it.  In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.