SlideShare una empresa de Scribd logo
1 de 46
JQUERY
WRITE LESS, DO MORE
Presented By
Nayab
Sheikh
Introduction to jQuery
• jQuery is a lightweight, open-source
JavaScript library that simplifies
interaction between HTML and
JavaScript
• It was and still being developed
by John Resig from Mozilla and was first
announced in January 2006
• It has a great community, great
documentation, tons of plugins, and it was
recently adopted by Microsoft
The current version is 1.3.2
(as of July 2009)
• Getting Started
• Download the latest version from
http://jquery.com
Copy the
jquery.js
and the
jquery-vsdoc.js
into your application folder
Reference it in your markup
• <script src=“jquery.js”/>
Reference it in your JS files:
• … or just drag it into the file
///<reference
path=“jquery.js”/>
jQuery Core
Concepts
jQuery Basics
• jQuery()
• This function is the heart of the jQuery library
• You use this function to fetch elements using CSS
selectors
• and wrap them in jQuery objects so we can manipulate
• them
• There’s a shorter version of the jQuery() function: $()
• $("h1");
• $(".important");
Document Ready
• $(document).ready(function(){
• // Your code here
• });
• jQuery has a simple statement that checks
the
• document and waits until it's ready to be
manipulated
What’s the problem with
JavaScript?
• JavaScript is a weakly typed, classless,
prototype based OO language, that can
also be used outside the browser. It is
not a browser DOM.
It means no more of this
• var tables =
document.getElementsByTagName("table");
• for (vart = 0; t<tables.length; t++) {
• var rows =
tables[t].getElementsByTagName("tr");
• for (vari = 1; i<rows.length; i += 2) {
• if
(!/(^|s)odd(s|$)/.test(rows[i].className))
{
• rows[i].className += " odd";
• }
• }
• };
Using jQuery we can do this
• $("tabletr:nth
• child(odd)").addClass("odd");
Using jQuery we can do
this
• jQuery("tabletr:ntchild(odd)"
). addClass("odd");
JQUERY FUNCTION
Using jQuery we can do
this
• jQuery("tabletr:nthchild(odd)").add
Class("odd");
JQUERY SELECTOR(CSS EXPRESSION)
Using jQuery we can do
this
• jQuery("tabletr:nth-
child(odd)").addClass("odd");
JQUERY METHOD
Hide divs with pure
JavaScript
• divs =
document.getElementByTagName(‘div’)
;
• for (i = 0; i < divs.length; i++) {
• divs[i].style.display = ‘none’;
• }
Hide divs with jQuery
• $(“div”).hide();
• It really is the
“write less, do more”
JavaScript Library!
Why use jQuery
• Helps us to simplify and speed up web
development
• Allows us to avoid common headaches
associated with browser development
• Provides a large pool of plugins
• Large and active community
• Tested on 50 browsers, 11 platforms
• Its for both coders and designers
how jQuery works?
• The $() function is an alias for the jQuery()
function .
• This returns a special Java-Script object.
• This JavaScript Object contains an array
of DOM elements that matches the selector.
• Selector is key thing in jQuery development.
• It is away to select node from DOM. This
Java-Script object possesses a large number
of useful predefined methods that can action
group of elements.
Starting with Jquery
• We load the Jquery library as any external JavaScript file.
script type="text/javascript"
src="jquery.js"></script>
• Now we loaded the Jquery library
• As almost everything we do when using jQuery reads or
manipulates the document object model (DOM), we need to
make sure that we start adding events etc. as soon as the DOM
is ready.
• To do this, we register a ready event for the document.
$(document).ready(function() {
// do stuff when DOM is ready
});
jQuery Syntax
• The jQuery syntax is tailor made for selecting HTML
elements and perform some action on the
element(s).
• Basic syntax is: $(selector).action()
– A dollar sign to define jQuery
– A (selector) to "query (or find)" HTML elements
– A jQuery action() to be performed on the
element(s)
jQuery Syntax Con,t
• Examples:
– $(this).hide() - hides current element
– $("p").hide() - hides all paragraphs
– $("p.test").hide() - hides all paragraphs with
class="test"
– $("#test").hide() - hides the element with id="test"
Selectors
• With normal JavaScript, finding elements can be extremely
cumbersome, unless you need to find a single element
which has a value specified in the ID attribute.
• jQuery can help you find elements based on their ID,
classes, types, attributes, values of attributes and much,
much more.
• It's based on CSS selectors and as you will see after going
through this that, it is extremely powerful
Selectors(cont’d)
• You can instantiate the jQuery object simply by writing
jQuery() or even shorter using the jQuery shortcut name:
$(). Therefore, selecting a set of elements is as simple as
this:
$(<query here>)
• With the jQuery object returned, you can then start using
and altering the element(s) you have matched.
Select DOM elements
• Selecting DOM elements through document based on the
css selectors.
• The #id selector
$(document).ready(function() {
$(“#d1").text("Test");
});
• This code will be applied on only one element whose ID
attribute is d1.
Select DOM
elements(cont’d)
• The .class selector
$(document).ready(function() {
$(“.para").text("Test");
});
• This code will be applied on all elements with the .para
class
Select DOM
elements(cont’d)
• The element selector
$(document).ready(function() {
$(“div").text("Test");
});
• This code will be applied on all <div> tags
Select DOM
elements(cont’d)
$(document).ready(function() {
$("#d2 span").text("Test");
});
• This code will be applied on all span elements within
the element whose ID attribute is #d2.
$(document).ready(function() {
$("span.bold").text("Test");
});
• This will match all span elements with "bold" as the
class
Some More Examples
• Syntax Description
• $(this) Current HTML element
• $("p) All <p> elements
• $("p.intro") All <p> elements with class="intro"
• $("p#intro") All <p> elements with id="intro"
• $("p.intro:first“) The first <p> element with class="intro"
• $(".intro“) All elements with class="intro"
• $("ul li:first") The first <li> element of the first <ul>
Find elements with a
specific attribute
• The most basic task when selecting elements
based on attributes is to find all the elements
which has a specific attribute.
• The syntax for this selector is a set of square
brackets with the name of the desired attribute
inside it, for instance [name] or [href].
Find elements with a
specific attribute(cont’d)
• Example.
$(document).ready(function() {
$(“[id]").text("Test");
});
• We use the attribute selector to find all elements on the
page which has an id attribute and then add text to it. As
mentioned, this will match elements with an id element no
matter what their value is
jQuery Events
• The jQuery event handling methods are core functions in
jQuery.
• Event handlers are method that are called when "something
happens" in HTML. The term "triggered (or "fired") by an
event" is often used.
• $("button").click(function() {..some code... } )
• EX:
– $(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
jQuery Events(cont’d)
• Here are some examples of event methods in jQuery:
• Event Method Description
• $(document).ready(function) Binds a function to the ready event of a
document
(when the document is finished loading)
• $(selector).click(function) Triggers, or binds a function to the click
event of selected elements
• $(selector).dblclick(function) Triggers, or binds a function to the
double click event of selected elements
A Few Examples
 Forms
 Chatboxes
 Menus
 Dropdowns
 Sliders
 Tabs
 Slideshows
 Games
jQuery Enhanced Forms
Menus and Dropdowns
Sliders and Slideshows
Pros:
• Large Community
• Ease of use
• Large library
• Strong opensource community. (Several
jQuery plugins available)
• Great documentation and tutorials
• Ajax support
Cons:
• Regular updates that change existing
behaviour
• Overhead of adding extra javascript to
page
• Learning curve may not be short for some
developers
Conclusions
• Conclusion In the end, jquery is popular for a
reason. It will make your website easier to control
and to access through any browser.
• By using this library, you can create or include
complex plug-ins in a matter of minutes. This will
make your website easier to use and as long as you
have imagination, the possibilities are endless.
Thank You

Más contenido relacionado

La actualidad más candente (20)

jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
jQuery
jQueryjQuery
jQuery
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
jQuery Presentasion
jQuery PresentasionjQuery Presentasion
jQuery Presentasion
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery Presentation
 
jQuery
jQueryjQuery
jQuery
 
Jquery library
Jquery libraryJquery library
Jquery library
 
Learn css3
Learn css3Learn css3
Learn css3
 
D3.js and SVG
D3.js and SVGD3.js and SVG
D3.js and SVG
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
jQuery Introduction
jQuery IntroductionjQuery Introduction
jQuery Introduction
 
jQuery Selectors
jQuery SelectorsjQuery Selectors
jQuery Selectors
 
jQuery Rescue Adventure
jQuery Rescue AdventurejQuery Rescue Adventure
jQuery Rescue Adventure
 
Jquery-overview
Jquery-overviewJquery-overview
Jquery-overview
 
J query training
J query trainingJ query training
J query training
 
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
 
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...
Learning jQuery made exciting in an interactive session by one of our team me...
 
JQuery
JQueryJQuery
JQuery
 
Jquery introduction
Jquery introductionJquery introduction
Jquery introduction
 

Destacado

Intro to jQuery - Tulsa Ruby Group
Intro to jQuery - Tulsa Ruby GroupIntro to jQuery - Tulsa Ruby Group
Intro to jQuery - Tulsa Ruby GroupBrad Vernon
 
jQuery Conference 2010 - Getting Involved
jQuery Conference 2010 - Getting InvolvedjQuery Conference 2010 - Getting Involved
jQuery Conference 2010 - Getting InvolvedRalph Whitbeck
 

Destacado (6)

Intro to jQuery - Tulsa Ruby Group
Intro to jQuery - Tulsa Ruby GroupIntro to jQuery - Tulsa Ruby Group
Intro to jQuery - Tulsa Ruby Group
 
jquery examples
jquery examplesjquery examples
jquery examples
 
jQuery Conference 2010 - Getting Involved
jQuery Conference 2010 - Getting InvolvedjQuery Conference 2010 - Getting Involved
jQuery Conference 2010 - Getting Involved
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
WordCamp London 2013
WordCamp London 2013WordCamp London 2013
WordCamp London 2013
 
J query 17-visual-cheat-sheet
J query 17-visual-cheat-sheetJ query 17-visual-cheat-sheet
J query 17-visual-cheat-sheet
 

Similar a Jquery (20)

JQuery
JQueryJQuery
JQuery
 
JQuery
JQueryJQuery
JQuery
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
jQuery
jQueryjQuery
jQuery
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
 
Jquery
JqueryJquery
Jquery
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
 
Getting started with jQuery
Getting started with jQueryGetting started with jQuery
Getting started with jQuery
 
jQuery besic
jQuery besicjQuery besic
jQuery besic
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 
JQuery_and_Ajax.pptx
JQuery_and_Ajax.pptxJQuery_and_Ajax.pptx
JQuery_and_Ajax.pptx
 
Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap Advanced JQuery Mobile tutorial with Phonegap
Advanced JQuery Mobile tutorial with Phonegap
 
J query module1
J query module1J query module1
J query module1
 
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)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
JavaScript!
JavaScript!JavaScript!
JavaScript!
 
J query
J queryJ query
J query
 
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jquery
 

Último

Chintamani Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ba...
Chintamani Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ba...Chintamani Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ba...
Chintamani Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ba...amitlee9823
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Sa...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Sa...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Sa...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Sa...Pooja Nehwal
 
Brand Analysis for reggaeton artist Jahzel.
Brand Analysis for reggaeton artist Jahzel.Brand Analysis for reggaeton artist Jahzel.
Brand Analysis for reggaeton artist Jahzel.GabrielaMiletti
 
Joshua Minker Brand Exploration Sports Broadcaster .pptx
Joshua Minker Brand Exploration Sports Broadcaster .pptxJoshua Minker Brand Exploration Sports Broadcaster .pptx
Joshua Minker Brand Exploration Sports Broadcaster .pptxsportsworldproductio
 
Call Girls In Chandapura ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Chandapura ☎ 7737669865 🥵 Book Your One night StandCall Girls In Chandapura ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Chandapura ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...gynedubai
 
Just Call Vip call girls Jammu Escorts ☎️9352988975 Two shot with one girl (J...
Just Call Vip call girls Jammu Escorts ☎️9352988975 Two shot with one girl (J...Just Call Vip call girls Jammu Escorts ☎️9352988975 Two shot with one girl (J...
Just Call Vip call girls Jammu Escorts ☎️9352988975 Two shot with one girl (J...gajnagarg
 
Miletti Gabriela_Vision Plan for artist Jahzel.pdf
Miletti Gabriela_Vision Plan for artist Jahzel.pdfMiletti Gabriela_Vision Plan for artist Jahzel.pdf
Miletti Gabriela_Vision Plan for artist Jahzel.pdfGabrielaMiletti
 
➥🔝 7737669865 🔝▻ Tirupati Call-girls in Women Seeking Men 🔝Tirupati🔝 Escor...
➥🔝 7737669865 🔝▻ Tirupati Call-girls in Women Seeking Men  🔝Tirupati🔝   Escor...➥🔝 7737669865 🔝▻ Tirupati Call-girls in Women Seeking Men  🔝Tirupati🔝   Escor...
➥🔝 7737669865 🔝▻ Tirupati Call-girls in Women Seeking Men 🔝Tirupati🔝 Escor...amitlee9823
 
Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...
Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...
Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...gajnagarg
 
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Gabriel_Carter_EXPOLRATIONpp.pptx........
Gabriel_Carter_EXPOLRATIONpp.pptx........Gabriel_Carter_EXPOLRATIONpp.pptx........
Gabriel_Carter_EXPOLRATIONpp.pptx........deejay178
 
Call Girls In Kr Puram ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Kr Puram ☎ 7737669865 🥵 Book Your One night StandCall Girls In Kr Puram ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Kr Puram ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
➥🔝 7737669865 🔝▻ Tumkur Call-girls in Women Seeking Men 🔝Tumkur🔝 Escorts S...
➥🔝 7737669865 🔝▻ Tumkur Call-girls in Women Seeking Men  🔝Tumkur🔝   Escorts S...➥🔝 7737669865 🔝▻ Tumkur Call-girls in Women Seeking Men  🔝Tumkur🔝   Escorts S...
➥🔝 7737669865 🔝▻ Tumkur Call-girls in Women Seeking Men 🔝Tumkur🔝 Escorts S...amitlee9823
 
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangaloreamitlee9823
 
Kannada Call Girls Mira Bhayandar WhatsApp +91-9930687706, Best Service
Kannada Call Girls Mira Bhayandar WhatsApp +91-9930687706, Best ServiceKannada Call Girls Mira Bhayandar WhatsApp +91-9930687706, Best Service
Kannada Call Girls Mira Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
Call Girls In Mahadevapura ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Mahadevapura ☎ 7737669865 🥵 Book Your One night StandCall Girls In Mahadevapura ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Mahadevapura ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
DMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdf
DMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdfDMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdf
DMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdfReemaKhan31
 
Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...gajnagarg
 
➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men 🔝Satara🔝 Escorts S...
➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men  🔝Satara🔝   Escorts S...➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men  🔝Satara🔝   Escorts S...
➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men 🔝Satara🔝 Escorts S...amitlee9823
 

Último (20)

Chintamani Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ba...
Chintamani Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ba...Chintamani Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ba...
Chintamani Call Girls Service: ☎ 7737669865 ☎ High Profile Model Escorts | Ba...
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Sa...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Sa...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Sa...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Sa...
 
Brand Analysis for reggaeton artist Jahzel.
Brand Analysis for reggaeton artist Jahzel.Brand Analysis for reggaeton artist Jahzel.
Brand Analysis for reggaeton artist Jahzel.
 
Joshua Minker Brand Exploration Sports Broadcaster .pptx
Joshua Minker Brand Exploration Sports Broadcaster .pptxJoshua Minker Brand Exploration Sports Broadcaster .pptx
Joshua Minker Brand Exploration Sports Broadcaster .pptx
 
Call Girls In Chandapura ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Chandapura ☎ 7737669865 🥵 Book Your One night StandCall Girls In Chandapura ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Chandapura ☎ 7737669865 🥵 Book Your One night Stand
 
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
 
Just Call Vip call girls Jammu Escorts ☎️9352988975 Two shot with one girl (J...
Just Call Vip call girls Jammu Escorts ☎️9352988975 Two shot with one girl (J...Just Call Vip call girls Jammu Escorts ☎️9352988975 Two shot with one girl (J...
Just Call Vip call girls Jammu Escorts ☎️9352988975 Two shot with one girl (J...
 
Miletti Gabriela_Vision Plan for artist Jahzel.pdf
Miletti Gabriela_Vision Plan for artist Jahzel.pdfMiletti Gabriela_Vision Plan for artist Jahzel.pdf
Miletti Gabriela_Vision Plan for artist Jahzel.pdf
 
➥🔝 7737669865 🔝▻ Tirupati Call-girls in Women Seeking Men 🔝Tirupati🔝 Escor...
➥🔝 7737669865 🔝▻ Tirupati Call-girls in Women Seeking Men  🔝Tirupati🔝   Escor...➥🔝 7737669865 🔝▻ Tirupati Call-girls in Women Seeking Men  🔝Tirupati🔝   Escor...
➥🔝 7737669865 🔝▻ Tirupati Call-girls in Women Seeking Men 🔝Tirupati🔝 Escor...
 
Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...
Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...
Just Call Vip call girls Firozabad Escorts ☎️9352988975 Two shot with one gir...
 
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Devanahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Gabriel_Carter_EXPOLRATIONpp.pptx........
Gabriel_Carter_EXPOLRATIONpp.pptx........Gabriel_Carter_EXPOLRATIONpp.pptx........
Gabriel_Carter_EXPOLRATIONpp.pptx........
 
Call Girls In Kr Puram ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Kr Puram ☎ 7737669865 🥵 Book Your One night StandCall Girls In Kr Puram ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Kr Puram ☎ 7737669865 🥵 Book Your One night Stand
 
➥🔝 7737669865 🔝▻ Tumkur Call-girls in Women Seeking Men 🔝Tumkur🔝 Escorts S...
➥🔝 7737669865 🔝▻ Tumkur Call-girls in Women Seeking Men  🔝Tumkur🔝   Escorts S...➥🔝 7737669865 🔝▻ Tumkur Call-girls in Women Seeking Men  🔝Tumkur🔝   Escorts S...
➥🔝 7737669865 🔝▻ Tumkur Call-girls in Women Seeking Men 🔝Tumkur🔝 Escorts S...
 
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Hosur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
Kannada Call Girls Mira Bhayandar WhatsApp +91-9930687706, Best Service
Kannada Call Girls Mira Bhayandar WhatsApp +91-9930687706, Best ServiceKannada Call Girls Mira Bhayandar WhatsApp +91-9930687706, Best Service
Kannada Call Girls Mira Bhayandar WhatsApp +91-9930687706, Best Service
 
Call Girls In Mahadevapura ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Mahadevapura ☎ 7737669865 🥵 Book Your One night StandCall Girls In Mahadevapura ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Mahadevapura ☎ 7737669865 🥵 Book Your One night Stand
 
DMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdf
DMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdfDMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdf
DMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdf
 
Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Jabalpur [ 7014168258 ] Call Me For Genuine Models ...
 
➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men 🔝Satara🔝 Escorts S...
➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men  🔝Satara🔝   Escorts S...➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men  🔝Satara🔝   Escorts S...
➥🔝 7737669865 🔝▻ Satara Call-girls in Women Seeking Men 🔝Satara🔝 Escorts S...
 

Jquery

  • 1. JQUERY WRITE LESS, DO MORE Presented By Nayab Sheikh
  • 2. Introduction to jQuery • jQuery is a lightweight, open-source JavaScript library that simplifies interaction between HTML and JavaScript
  • 3. • It was and still being developed by John Resig from Mozilla and was first announced in January 2006
  • 4. • It has a great community, great documentation, tons of plugins, and it was recently adopted by Microsoft
  • 5. The current version is 1.3.2 (as of July 2009)
  • 7. • Download the latest version from http://jquery.com
  • 9. Reference it in your markup • <script src=“jquery.js”/>
  • 10. Reference it in your JS files: • … or just drag it into the file ///<reference path=“jquery.js”/>
  • 12. jQuery Basics • jQuery() • This function is the heart of the jQuery library • You use this function to fetch elements using CSS selectors • and wrap them in jQuery objects so we can manipulate • them • There’s a shorter version of the jQuery() function: $() • $("h1"); • $(".important");
  • 13. Document Ready • $(document).ready(function(){ • // Your code here • }); • jQuery has a simple statement that checks the • document and waits until it's ready to be manipulated
  • 14. What’s the problem with JavaScript? • JavaScript is a weakly typed, classless, prototype based OO language, that can also be used outside the browser. It is not a browser DOM.
  • 15. It means no more of this • var tables = document.getElementsByTagName("table"); • for (vart = 0; t<tables.length; t++) { • var rows = tables[t].getElementsByTagName("tr"); • for (vari = 1; i<rows.length; i += 2) { • if (!/(^|s)odd(s|$)/.test(rows[i].className)) { • rows[i].className += " odd"; • } • } • };
  • 16. Using jQuery we can do this • $("tabletr:nth • child(odd)").addClass("odd");
  • 17. Using jQuery we can do this • jQuery("tabletr:ntchild(odd)" ). addClass("odd"); JQUERY FUNCTION
  • 18. Using jQuery we can do this • jQuery("tabletr:nthchild(odd)").add Class("odd"); JQUERY SELECTOR(CSS EXPRESSION)
  • 19. Using jQuery we can do this • jQuery("tabletr:nth- child(odd)").addClass("odd"); JQUERY METHOD
  • 20. Hide divs with pure JavaScript • divs = document.getElementByTagName(‘div’) ; • for (i = 0; i < divs.length; i++) { • divs[i].style.display = ‘none’; • }
  • 21. Hide divs with jQuery • $(“div”).hide();
  • 22. • It really is the “write less, do more” JavaScript Library!
  • 23. Why use jQuery • Helps us to simplify and speed up web development • Allows us to avoid common headaches associated with browser development • Provides a large pool of plugins • Large and active community • Tested on 50 browsers, 11 platforms • Its for both coders and designers
  • 24. how jQuery works? • The $() function is an alias for the jQuery() function . • This returns a special Java-Script object. • This JavaScript Object contains an array of DOM elements that matches the selector. • Selector is key thing in jQuery development. • It is away to select node from DOM. This Java-Script object possesses a large number of useful predefined methods that can action group of elements.
  • 25. Starting with Jquery • We load the Jquery library as any external JavaScript file. script type="text/javascript" src="jquery.js"></script> • Now we loaded the Jquery library • As almost everything we do when using jQuery reads or manipulates the document object model (DOM), we need to make sure that we start adding events etc. as soon as the DOM is ready. • To do this, we register a ready event for the document. $(document).ready(function() { // do stuff when DOM is ready });
  • 26. jQuery Syntax • The jQuery syntax is tailor made for selecting HTML elements and perform some action on the element(s). • Basic syntax is: $(selector).action() – A dollar sign to define jQuery – A (selector) to "query (or find)" HTML elements – A jQuery action() to be performed on the element(s)
  • 27. jQuery Syntax Con,t • Examples: – $(this).hide() - hides current element – $("p").hide() - hides all paragraphs – $("p.test").hide() - hides all paragraphs with class="test" – $("#test").hide() - hides the element with id="test"
  • 28. Selectors • With normal JavaScript, finding elements can be extremely cumbersome, unless you need to find a single element which has a value specified in the ID attribute. • jQuery can help you find elements based on their ID, classes, types, attributes, values of attributes and much, much more. • It's based on CSS selectors and as you will see after going through this that, it is extremely powerful
  • 29. Selectors(cont’d) • You can instantiate the jQuery object simply by writing jQuery() or even shorter using the jQuery shortcut name: $(). Therefore, selecting a set of elements is as simple as this: $(<query here>) • With the jQuery object returned, you can then start using and altering the element(s) you have matched.
  • 30. Select DOM elements • Selecting DOM elements through document based on the css selectors. • The #id selector $(document).ready(function() { $(“#d1").text("Test"); }); • This code will be applied on only one element whose ID attribute is d1.
  • 31. Select DOM elements(cont’d) • The .class selector $(document).ready(function() { $(“.para").text("Test"); }); • This code will be applied on all elements with the .para class
  • 32. Select DOM elements(cont’d) • The element selector $(document).ready(function() { $(“div").text("Test"); }); • This code will be applied on all <div> tags
  • 33. Select DOM elements(cont’d) $(document).ready(function() { $("#d2 span").text("Test"); }); • This code will be applied on all span elements within the element whose ID attribute is #d2. $(document).ready(function() { $("span.bold").text("Test"); }); • This will match all span elements with "bold" as the class
  • 34. Some More Examples • Syntax Description • $(this) Current HTML element • $("p) All <p> elements • $("p.intro") All <p> elements with class="intro" • $("p#intro") All <p> elements with id="intro" • $("p.intro:first“) The first <p> element with class="intro" • $(".intro“) All elements with class="intro" • $("ul li:first") The first <li> element of the first <ul>
  • 35. Find elements with a specific attribute • The most basic task when selecting elements based on attributes is to find all the elements which has a specific attribute. • The syntax for this selector is a set of square brackets with the name of the desired attribute inside it, for instance [name] or [href].
  • 36. Find elements with a specific attribute(cont’d) • Example. $(document).ready(function() { $(“[id]").text("Test"); }); • We use the attribute selector to find all elements on the page which has an id attribute and then add text to it. As mentioned, this will match elements with an id element no matter what their value is
  • 37. jQuery Events • The jQuery event handling methods are core functions in jQuery. • Event handlers are method that are called when "something happens" in HTML. The term "triggered (or "fired") by an event" is often used. • $("button").click(function() {..some code... } ) • EX: – $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); });
  • 38. jQuery Events(cont’d) • Here are some examples of event methods in jQuery: • Event Method Description • $(document).ready(function) Binds a function to the ready event of a document (when the document is finished loading) • $(selector).click(function) Triggers, or binds a function to the click event of selected elements • $(selector).dblclick(function) Triggers, or binds a function to the double click event of selected elements
  • 39. A Few Examples  Forms  Chatboxes  Menus  Dropdowns  Sliders  Tabs  Slideshows  Games
  • 43. Pros: • Large Community • Ease of use • Large library • Strong opensource community. (Several jQuery plugins available) • Great documentation and tutorials • Ajax support
  • 44. Cons: • Regular updates that change existing behaviour • Overhead of adding extra javascript to page • Learning curve may not be short for some developers
  • 45. Conclusions • Conclusion In the end, jquery is popular for a reason. It will make your website easier to control and to access through any browser. • By using this library, you can create or include complex plug-ins in a matter of minutes. This will make your website easier to use and as long as you have imagination, the possibilities are endless.