简体   繁体   English

Zepto等效于jQuery prev([selector])

[英]Zepto equivalent to jQuery prev([selector])

Does Zepto have an equivalent to jQuery's prev([selector])? Zepto是否与jQuery的prev([selector])等效? I have the following HTML code: 我有以下HTML代码:

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

In jQuery I would do something like: 在jQuery中,我将执行以下操作:

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

What's the best way to accomplish this task in Zepto? 在Zepto中完成此任务的最佳方法是什么? According to the API, it seems that Zepto's prev() method does not accept a selector parameter, but maybe I'm overlooking something. 根据API,Zepto的prev()方法似乎不接受选择器参数,但是也许我忽略了某些东西。

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() Zepto具有prev()

From the docs: 从文档:

prev() ⇒ collection 上一页()⇒集合

prev(selector) ⇒ collection v1.0+ 上一页(选择器)⇒集合v1.0 +

Get the previous sibling—optionally filtered by selector—of each element in the collection. 获取集合中每个元素的上一个同级(可选地由选择器过滤)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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