Skip to main content
Version: 0.17.0

leftOf

production

Filters for an element left of another element.

Takes an optional parameter index to select the nth element (starting with 0)

Examples:

--------------  --------------  --------------
| leftEl1 | | leftEl0 | | rightEl |
-------------- -------------- --------------

// Returns leftEl0 because leftEl0 is the first element left of rightEl
...leftEl().leftOf().rightEl()
...leftEl().leftOf(0).rightEl()
// Returns leftEl1 because leftEl1 is the second element left of rightEl
...leftEl().leftOf(1).rightEl()
// Returns no element because rightEl is left of leftEl
...rightEl().leftOf().leftEl()

  • @param {number} [optionalIndex=0] - element index