Currently Viewing Posts Tagged XPath

$() Factory Function, CSS Selectors, XPath Selectors, Custom Selectors

No matter which type of selector we want to use in jQuery – be it CSS, XPath, or custom – we always start with the dollar sign and parentheses: $()
$() Factory Function
Let’s see some more common examples:
A tag name: $(‘p’) gets all paragraphs in the document.
An ID: $(‘#some-id’) gets the single element in the document that has the corresponding some-id ID.
A class: $(‘.some-class’) gets all elements in the document that have a class of some-class.
CSS Selectors
Chile combinator
>

$(‘#selected-id > li’)

Find each liste item (li) that is a child (>) of an element with an ID of selected-id (#selected-id).
Negation pseudo-class
not

$(‘#selected-id > li:not(.horizontal)’)

Find each list item that do not have a class of horizontal, which is a child of #selected-id.

Continue reading “$() Factory Function, CSS Selectors, XPath Selectors, Custom Selectors”

  • Archives