JQuery: Getting Pretty Much Everything in the DOM

$('div:hidden') gets all 'div' elements which have their 'display' style attribute set to 'hidden'

$('li:eq(0)') gets the first item in the list

$('li:lt(3)') gets the first 3 items in the list (0 based)

$('li:even') gets all list items with a even index (0 based)

$('li:not(.some)') gets the lost items which do not have the css class ‘some’

$('p, li.some') gets all 'p' elements as well as all 'li' elements with a css class of 'some'

$('li .some> p') gets all 'p' elements which are children of any element with a css class of 'some' which are in turn children of a 'li' element

$('p a[@href*=http]') gets all ‘a’ elements which are children of a ‘p’ element that have a ‘http’ within the ‘href’ attribute

$('li + li > a[@href$=zip]') gets all 'a' elements which have 'zip' in the 'href' attribute which are children of a 'li' element which is in turn the child of another 'li' element

Full List of DOM Traversing Functions

Published by

Tim Clark

Experienced Business Owner, Chief Information Officer, Vice President, Chief Software Architect, Application Architect, Project Manager, Software Developer, Senior Web Developer, Graphic Designer & 3D Modeler, University Instructor, University Program Chair, Academic Director. Specialties: Ruby, Ruby on Rails, JavaScript, JQuery, AJAX, Node.js, React.js, Angular.js, MySQL, PostgreSQL, MongoDB, SQL Server, Responsive Design, HTML5, XHTML, CSS3, C#, ASP.net, Project Management, System Design/Architecture, Web Design, Web Development, Adobe CS6 (Photoshop, Illustrator)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s