使用jQuery多选择框获取未选择的列表 [英] get unselected list using jquery multi select box

查看:58
本文介绍了使用jQuery多选择框获取未选择的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jquery多项选择框来显示并在它们之间移动两个清单.我想检索尚未选择的元素列表.我现在正在尝试:

i am using a jquery multi select box to show and move between two lists. i want to retrieve the list of elements which have not been selected. i am trying this right now:

var notSelected = $("#myList").find('option').attr('selected',false);

但是当我尝试警报时,它为我提供了 notSelected 作为 HTMLElement 的类型.这是正确的技术吗?我应该如何从中获取清单?还有其他办法吗?

but when i try an alert, it gives me type of notSelected as HTMLElement . is this the right technique? how am i supposed to get the list from this? is there any other way?

推荐答案

尝试

var notSelected = $("#myList").find('option').not(':selected');
var array = notSelected.map(function () {
    return this.value;
}).get();

您正在做的是将#myList中所有选项的selected属性值设置为false

What you are doing is to set the selected attribute value of all options in #myList to false

这篇关于使用jQuery多选择框获取未选择的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆