我有一个节点列表:
<div id="node-1"></div>
<div id="node-2" class="current"></div>
<div id="node-3"></div>
<div id="node-4"></div>
<div id="node-5"></div>
Run Code Online (Sandbox Code Playgroud)
当使用$(".current")as选择器(node-2)时,如何使用Zepto获取所有节点3-5 ?
这应该工作.几乎像http://api.jquery.com/nextAll/和http://api.jquery.com/prevAll/
;(function($){
var e = {
nextAll: function(s) {
var $els = $(), $el = this.next()
while( $el.length ) {
if(typeof s === 'undefined' || $el.is(s)) $els = $els.add($el)
$el = $el.next()
}
return $els
},
prevAll: function(s) {
var $els = $(), $el = this.prev()
while( $el.length ) {
if(typeof s === 'undefined' || $el.is(s)) $els = $els.add($el)
$el = $el.prev()
}
return $els
}
}
$.extend( $.fn, e )
})(Zepto);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1279 次 |
| 最近记录: |