问题
Is there any JQuery method/implementation that equivalent to YUI.getElementsBy?
YUI.getElementsBy ( method , tag , root , apply , o , overrides )
thanks, Simon
回答1:
The description of that method is as follows:
Array getElementsBy ( method , tag , root , apply , o , overrides )
Returns an array of HTMLElements that pass the test applied by supplied boolean method
You can replicate that functionality in jQuery with the filter method, and if you want to return an array of HTMLElement objects, you can use get (otherwise you will have a jQuery object):
$(selector).filter(method).get();
In the jQuery version, both tag
and root
arguments would be combined into the selector.
来源:https://stackoverflow.com/questions/10428409/yui-getelementsby-equivalent-to-jquery