简体   繁体   English

从jquery插件中的multiselect Group获取值

[英]Getting the values from the multiselect Group in jquery plugin

I am working on multiselect group. 我正在研究多选组。 Here is the link i have populated some data in the multiselect group and the users can select their requirements in that. 这是我在多选组中填充一些数据的链接,用户可以在其中选择他们的要求。 http://vignesh.gvignesh.org/chose/chose.php http://vignesh.gvignesh.org/chose/chose.php

Here once show selected button is clicked i am calling javascript function. 这里一旦显示所选按钮被点击我正在调用javascript函数。

function chos()
  {
        var a = $(".chzn-select").chosen(); 
        alert(a);
  }

it is not showing the selected values in alert box. 它没有在警告框中显示所选值。 Some [object][object] is displayed. 显示一些[对象] [对象]。 i dont know how to get the selected values. 我不知道如何获得选定的值。 If my javascript function for getting the values is wrong kindly let me know the new function. 如果我的javascript函数获取值是错误的,请让我知道新函数。

Thanks in Advance. 提前致谢。

Just use $("#chossen").val() , which returns an array of value s that are currently selected. 只需使用$("#chossen").val() ,它返回当前选中的value s数组。

To get the actual option elements that are selected, try $("#chossen").find("option:selected"); 要获取所选的实际option元素,请尝试$("#chossen").find("option:selected"); , and then loop through those (obviously) - in case you want to get their text . ,然后循环通过那些(显然) - 如果你想得到他们的text

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM