hawkharris
hawkharris

Reputation: 2650

Zepto equivalent to jQuery prev([selector])

Does Zepto have an equivalent to jQuery's prev([selector])? I have the following HTML code:

<span class='error-placeholder'></span><input type='text' class='email'>

In jQuery I would do something like:

$('.email').prev('.error-placeholder').text('That email is invalid, Chief.'); 

What's the best way to accomplish this task in Zepto? According to the API, it seems that Zepto's prev() method does not accept a selector parameter, but maybe I'm overlooking something.

EDIT: The example I provided is not ideal. In this case, I could just leave out the selector. But I will be dealing with cases in which there are other elements, and I will need the ability to select a specific one.

Upvotes: 1

Views: 305

Answers (1)

dezman
dezman

Reputation: 19368

Zepto has prev()

From the docs:

prev() ⇒ collection

prev(selector) ⇒ collection v1.0+

Get the previous sibling—optionally filtered by selector—of each element in the collection.

Upvotes: 1

Related Questions