开发者

How do I return a subset in jQuery plugin?

开发者 https://www.devze.com 2023-01-02 15:07 出处:网络
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

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

精彩评论

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