简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM