我如何使用 Jquery 查找页面中的所有下拉列表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1664686/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:57:12  来源:igfitidea点击:

How do i find all drop down lists in a page using Jquery

jquery

提问by Greens

How do i loop thru all dropdown boxes in JQuery?

我如何遍历 JQuery 中的所有下拉框?

回答by Marek Karbarz

something like this should do the trick

这样的事情应该可以解决问题

$("select").each(function() {
    //do something with the select $(this) will give you the select element
});

回答by nickf

$("select")will include all the combo boxes too. To just get the drop down menus, use this:

$("select")也将包括所有组合框。要获取下拉菜单,请使用以下命令:

$("select:not([size])")

To answer your other question:

回答你的另一个问题:

How do I loop thru in multiple divs? Can I do $('#mydivname').find('select').each(function(){ });??

如何在多个 div 中循环?我可以$('#mydivname').find('select').each(function(){ });吗??

$('#mydivname select:not[size]').each(...)