Jquery: Selection within a selection

廉价感情. 提交于 2019-12-28 07:02:30

问题


I have an array of different elements stored from a previous selection, call it 'a'.

How do i then do another select from this previous selection (a) and just return elements of type input?


回答1:


a.filter('input').each(function() {
    alert('My name is ' + $(this).attr('name'));
});

To just get a selection from the current selection this way:

var $inputs = a.filter('input');

You can even comma separate selectors:

var $els = a.filter('input, .fooMonger, #something');

See http://docs.jquery.com/Traversing/filter




回答2:


$('input', a);



回答3:


$(a).find("input")


来源:https://stackoverflow.com/questions/1266604/jquery-selection-within-a-selection

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