什么';s等效于getSelected()(mootools 1.1)

什么';s等效于getSelected()(mootools 1.1),select,mootools,Select,Mootools,在mootools 1.2中,使用getSelected可以轻松地在多重选择中获取选定选项: // code 1 $('my_select').getSelected().each(function(opt) { // stuff }); mootools 1.1中是否有类似的工具,或者我必须使用getChildren()并检查是否已选中它 我现在所拥有的: // code 2 // get all options $('my_select').getChildren().each(

在mootools 1.2中,使用getSelected可以轻松地在多重选择中获取选定选项:

// code 1
$('my_select').getSelected().each(function(opt) { 
    // stuff
});
mootools 1.1中是否有类似的工具,或者我必须使用getChildren()并检查是否已选中它

我现在所拥有的:

// code 2
// get all options
$('my_select').getChildren().each(function(g) {
    // if option is selected
    if(g.selected == true)
    {
       // do some stuff
    }
});
$('my_select')。getSelected()在1.2.4中,对吗?不确定是不是1.1。如果没有,你可以试试

$$('#my_select option').filter(function(option){ return option.selected; })

如果过滤器不存在,则设置为坏:(您必须手动执行…

如果我理解正确,最终结果与上面代码段2中的结果类似。这不是我所期望的。我希望只获取所选项目,而不必遍历每个选项。如果getSelected不存在,恐怕我们别无选择。至少筛选器返回array、 所以你仍然可以将它链接到每个