method

match

Importance_1
Ruby on Rails latest stable (v7.1.3.2) - 0 notes - Class: HTML::Selector

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v4.1.8) is shown here.

These similar methods exist in v7.1.3.2:

match(element, first_only = false) public

Matches an element against the selector.

For a simple selector this method returns an array with the element if the element matches, nil otherwise.

For a complex selector (sibling and descendant) this method returns an array with all matching elements, nil if no match is found.

Use +first_only=true+ if you are only interested in the first element.

For example:

if selector.match(element)
  puts "Element is a login form"
end
Show source
Register or log in to add new notes.