SlideShare a Scribd company logo
jQuery SlideCasting
     #1 jQuery Selectors
Quick links

• http://jquery.com/
• http://api.jquery.com/
• http://getfirebug.com
• http://www.slideshare.net/search/slideshow?
  q=jquery
Query selectors are one of the most important
aspects of the jQuery library. These selectors use
familiar CSS syntax to allow page authors to quickly
and easily identify any set of page elements to
operate upon with the jQuery library methods.
Understanding jQuery selectors is the key to using
the jQuery library most effectively. -- Refcardz
In this chapter we will play using jQuery
on SlideShare’s homepage since it is using
jQuery. And for convenience I will use
Firebug console so that even you can run
it with your Firebug console when we
proceed further.
• $ == jQuery and vice versa. Here I will use
  just jQuery every where.

• jQuery(“*”) - Wild card selector and
  selects all the elements in a document.
jQuery(“*”)




Here jQuery(“*”) gives out all the elements present
              inside the document.
• jQuery(“#id”) - This selector selects an
  element with the given id.

• I am going to select the element in the
  homepage with id “player”.
jQuery(“#player”)




You can see that it selects the element with id “player”
• Lets say I want to get all the elements
  which has class “docinfo” on the homepage.

• It is really simple to get all those elements
  with jQuery.

• jQuery(“.docinfo”) - Gets all the elements
  with the given class name.
jQuery(“.docinfo”)




I get all the elements with class name “docinfo” in a neat
  array so that I can manipulate them easily by iterating.
• Selecting elements with their tag names is
  also so simple in jQuery.

• jQuery(“tagname”) will return all matching
  elements with tagname.

• Lets select all elements with “div” tag.
jQuery(“div”)




I get all the elements with “div” tag in a neat array.
• Here is the best deal you get with jQuery
• Lets say I want to select element with id
  “player”, elements with class name
  “docinfo” and elements with tags “ul” and
  “p”.

• I can get all the elements in a single simple
  command.

• jQuery(“#player, .docinfo, ul, p”)
jQuery(“#player, .docinfo, ul, p”)




Isn’t this great? Let’s get deep into selectors now.
• jQuery(“ancestor descendant”) - This will
  select all child elements that are
  descendant of parent element.

• jQuery(“li a”) - This will return all “a” that
  are a descendant of “li”.
jQuery(“li a”)




I get all “a” elements descending “li” alone.
• jQuery(“a > b”) - This will select all “b”
  elements which are a child element of “a”.

• How this one differs from the previous
  selector?

• <li><span><a>something</a></span></li>
• If you use the previous selector i.e
  jQuery(“li a”) for the above html it will
  return an array with the “a” element. But if
  you use jQuery(“li > a”) it will return an
  empty array since it will look only for
  immediate children.
jQuery(“li > a”)




If you compare this with previous result you will know the
     actual difference in the size of the array returned.
• jQuery(“prev next”) - This will return all
  “next” elements that are immediate sibling
  of “prev” elements.

• jQuery(“label+input”) returns all “input”
  which comes next to a “label” element.
jQuery(“label+input”)




This has returned only the “input” elements which comes
     right after a “label” element (immediate sibling)
• jQuery(“prev ~ siblings”) - This will return
  all matching siblings after the “prev”
  element.

• jQuery(“div ~ p”) will return all “p”
  elements that are siblings after the “div”
  element.
jQuery(“div ~ p”)




This has returned all “p” elements that are siblings to
                   “div” elements.
• Hope you have learnt some serious stuff
  with jQuery this week.

• Next week we will see more about jQuery
  filters which gives you more control over
  jQuery selectors.

• Thank you.

More Related Content

What's hot

J query
J queryJ query
J query
Manav Prasad
 
JQuery
JQueryJQuery
JQuery
DevTalk
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
dmethvin
 
Jquery-overview
Jquery-overviewJquery-overview
Jquery-overview
Isfand yar Khan
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
Marc Grabanski
 
jQuery
jQueryjQuery
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQueryAngel Ruiz
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
NexThoughts Technologies
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
Anis Ahmad
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
Alan Hecht
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
Simon Willison
 
Jquery introduction
Jquery introductionJquery introduction
Jquery introduction
musrath mohammad
 
Organizing Code with JavascriptMVC
Organizing Code with JavascriptMVCOrganizing Code with JavascriptMVC
Organizing Code with JavascriptMVC
Thomas Reynolds
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
manugoel2003
 
jQuery
jQueryjQuery
Write Less Do More
Write Less Do MoreWrite Less Do More
Write Less Do More
Remy Sharp
 
Jquery for Beginners
Jquery for BeginnersJquery for Beginners
Jquery for Beginners
Mohd Abdul Baquee
 

What's hot (20)

J query
J queryJ query
J query
 
JQuery
JQueryJQuery
JQuery
 
Jquery
JqueryJquery
Jquery
 
Learn css3
Learn css3Learn css3
Learn css3
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
 
Jquery-overview
Jquery-overviewJquery-overview
Jquery-overview
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
jQuery
jQueryjQuery
jQuery
 
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQuery
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
Jquery introduction
Jquery introductionJquery introduction
Jquery introduction
 
Organizing Code with JavascriptMVC
Organizing Code with JavascriptMVCOrganizing Code with JavascriptMVC
Organizing Code with JavascriptMVC
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
J query training
J query trainingJ query training
J query training
 
jQuery
jQueryjQuery
jQuery
 
Write Less Do More
Write Less Do MoreWrite Less Do More
Write Less Do More
 
Jquery for Beginners
Jquery for BeginnersJquery for Beginners
Jquery for Beginners
 

Viewers also liked

Beyond the Final Frontier of jQuery Selectors
Beyond the Final Frontier of jQuery SelectorsBeyond the Final Frontier of jQuery Selectors
Beyond the Final Frontier of jQuery Selectors
Alexander Shopov
 
Jquery.cheatsheet.1.4
Jquery.cheatsheet.1.4Jquery.cheatsheet.1.4
Jquery.cheatsheet.1.4
Сергей Ткалич
 
JQuery selectors
JQuery selectors JQuery selectors
JQuery selectors
chandrashekher786
 
Selectors & Traversing
Selectors & TraversingSelectors & Traversing
Selectors & Traversingswainet
 
jQuery filters - Part 1
jQuery filters - Part 1jQuery filters - Part 1
jQuery filters - Part 1
jQuerySlideCasts
 
The Value of Search Engine Optimization
The Value of Search Engine OptimizationThe Value of Search Engine Optimization
The Value of Search Engine Optimization
Mannix Marketing
 

Viewers also liked (7)

Beyond the Final Frontier of jQuery Selectors
Beyond the Final Frontier of jQuery SelectorsBeyond the Final Frontier of jQuery Selectors
Beyond the Final Frontier of jQuery Selectors
 
Jquery.cheatsheet.1.4
Jquery.cheatsheet.1.4Jquery.cheatsheet.1.4
Jquery.cheatsheet.1.4
 
JQuery selectors
JQuery selectors JQuery selectors
JQuery selectors
 
Selectors & Traversing
Selectors & TraversingSelectors & Traversing
Selectors & Traversing
 
jQuery filters - Part 1
jQuery filters - Part 1jQuery filters - Part 1
jQuery filters - Part 1
 
Advanced JQuery Selectors
Advanced JQuery SelectorsAdvanced JQuery Selectors
Advanced JQuery Selectors
 
The Value of Search Engine Optimization
The Value of Search Engine OptimizationThe Value of Search Engine Optimization
The Value of Search Engine Optimization
 

Similar to jQuery Selectors

J query introduction
J query introductionJ query introduction
J query introduction
SMS_VietNam
 
FFW Gabrovo PMG - jQuery
FFW Gabrovo PMG - jQueryFFW Gabrovo PMG - jQuery
FFW Gabrovo PMG - jQuery
Toni Kolev
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Zeeshan Khan
 
Web technologies-course 11.pptx
Web technologies-course 11.pptxWeb technologies-course 11.pptx
Web technologies-course 11.pptx
Stefan Oprea
 
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
Sean Burgess
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQueryLaila Buncab
 
Getting started with jQuery
Getting started with jQueryGetting started with jQuery
Getting started with jQuery
Gill Cleeren
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Gunjan Kumar
 
Dojo Confessions
Dojo ConfessionsDojo Confessions
Dojo Confessions
Rebecca Murphey
 
J Query Introduction And JQuery Selectors
J Query Introduction And JQuery SelectorsJ Query Introduction And JQuery Selectors
J Query Introduction And JQuery Selectors
Anand Kumar Rajana
 
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdfUnit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
RAVALCHIRAG1
 
jQuery basics for Beginners
jQuery basics for BeginnersjQuery basics for Beginners
jQuery basics for Beginners
Pooja Saxena
 
NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05
lrdesign
 
Iniciando com jquery
Iniciando com jqueryIniciando com jquery
Iniciando com jquery
Danilo Sousa
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Seble Nigussie
 

Similar to jQuery Selectors (20)

J query introduction
J query introductionJ query introduction
J query introduction
 
FFW Gabrovo PMG - jQuery
FFW Gabrovo PMG - jQueryFFW Gabrovo PMG - jQuery
FFW Gabrovo PMG - jQuery
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Web technologies-course 11.pptx
Web technologies-course 11.pptxWeb technologies-course 11.pptx
Web technologies-course 11.pptx
 
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
 
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
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Jquery
JqueryJquery
Jquery
 
Dojo Confessions
Dojo ConfessionsDojo Confessions
Dojo Confessions
 
J Query Introduction And JQuery Selectors
J Query Introduction And JQuery SelectorsJ Query Introduction And JQuery Selectors
J Query Introduction And JQuery Selectors
 
J query module1
J query module1J query module1
J query module1
 
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdfUnit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
Unit 1 - What is jQuery_Why jQuery_Syntax_Selectors.pdf
 
jQuery basics for Beginners
jQuery basics for BeginnersjQuery basics for Beginners
jQuery basics for Beginners
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
JQuery
JQueryJQuery
JQuery
 
JQuery
JQueryJQuery
JQuery
 
NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05
 
Iniciando com jquery
Iniciando com jqueryIniciando com jquery
Iniciando com jquery
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 

Recently uploaded

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 

Recently uploaded (20)

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 

jQuery Selectors

  • 1. jQuery SlideCasting #1 jQuery Selectors
  • 2. Quick links • http://jquery.com/ • http://api.jquery.com/ • http://getfirebug.com • http://www.slideshare.net/search/slideshow? q=jquery
  • 3. Query selectors are one of the most important aspects of the jQuery library. These selectors use familiar CSS syntax to allow page authors to quickly and easily identify any set of page elements to operate upon with the jQuery library methods. Understanding jQuery selectors is the key to using the jQuery library most effectively. -- Refcardz
  • 4. In this chapter we will play using jQuery on SlideShare’s homepage since it is using jQuery. And for convenience I will use Firebug console so that even you can run it with your Firebug console when we proceed further.
  • 5. • $ == jQuery and vice versa. Here I will use just jQuery every where. • jQuery(“*”) - Wild card selector and selects all the elements in a document.
  • 6. jQuery(“*”) Here jQuery(“*”) gives out all the elements present inside the document.
  • 7. • jQuery(“#id”) - This selector selects an element with the given id. • I am going to select the element in the homepage with id “player”.
  • 8. jQuery(“#player”) You can see that it selects the element with id “player”
  • 9. • Lets say I want to get all the elements which has class “docinfo” on the homepage. • It is really simple to get all those elements with jQuery. • jQuery(“.docinfo”) - Gets all the elements with the given class name.
  • 10. jQuery(“.docinfo”) I get all the elements with class name “docinfo” in a neat array so that I can manipulate them easily by iterating.
  • 11. • Selecting elements with their tag names is also so simple in jQuery. • jQuery(“tagname”) will return all matching elements with tagname. • Lets select all elements with “div” tag.
  • 12. jQuery(“div”) I get all the elements with “div” tag in a neat array.
  • 13. • Here is the best deal you get with jQuery • Lets say I want to select element with id “player”, elements with class name “docinfo” and elements with tags “ul” and “p”. • I can get all the elements in a single simple command. • jQuery(“#player, .docinfo, ul, p”)
  • 14. jQuery(“#player, .docinfo, ul, p”) Isn’t this great? Let’s get deep into selectors now.
  • 15. • jQuery(“ancestor descendant”) - This will select all child elements that are descendant of parent element. • jQuery(“li a”) - This will return all “a” that are a descendant of “li”.
  • 16. jQuery(“li a”) I get all “a” elements descending “li” alone.
  • 17. • jQuery(“a > b”) - This will select all “b” elements which are a child element of “a”. • How this one differs from the previous selector? • <li><span><a>something</a></span></li> • If you use the previous selector i.e jQuery(“li a”) for the above html it will return an array with the “a” element. But if you use jQuery(“li > a”) it will return an empty array since it will look only for immediate children.
  • 18. jQuery(“li > a”) If you compare this with previous result you will know the actual difference in the size of the array returned.
  • 19. • jQuery(“prev next”) - This will return all “next” elements that are immediate sibling of “prev” elements. • jQuery(“label+input”) returns all “input” which comes next to a “label” element.
  • 20. jQuery(“label+input”) This has returned only the “input” elements which comes right after a “label” element (immediate sibling)
  • 21. • jQuery(“prev ~ siblings”) - This will return all matching siblings after the “prev” element. • jQuery(“div ~ p”) will return all “p” elements that are siblings after the “div” element.
  • 22. jQuery(“div ~ p”) This has returned all “p” elements that are siblings to “div” elements.
  • 23. • Hope you have learnt some serious stuff with jQuery this week. • Next week we will see more about jQuery filters which gives you more control over jQuery selectors. • Thank you.