开发者

How do I return a subset in jQuery plugin?

By default it's like this:

$.fn.ellipsis = function() {
...
return this.each(function(){
  //do some operation on each element here to see if it qualifies

}
}

But now I want to return a subset of all, only those qu开发者_如何学JAVAalify in this.each(function() {}),

how to modify the code so that it finally returns only those that qualify?


Check out jQuery's filter function: http://api.jquery.com/filter/


i would suggest using jquery.grep if your filtering mechanism is a function. makes it really easy to pull out just the items in the array that you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜