YUI.getElementsBy equivalent to jQuery

北战南征 提交于 2019-12-25 02:34:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!