multiselect获取选中的多个下拉项的值(逗号分割的字符串)

 1 /*传入下拉select标签*/
 2  function get_selected(mslt_employees) {
 3             var emplo =mslt_employees.multiselect("getChecked").map(function () {
 4                 return this.value;
 5             }).get();
 6 
 7             if (isArray(emplo)) {//判断是否数组
 8                 list_str = emplo.join(",");//数组转为逗号分隔的字符串
 9             } else {
10                 var list_str = emplo;
11             }
12             return list_str;
13         }
//判断是否数组的方法
isArray = function (source) {
            return '[object Array]' == Object.prototype.toString.call(source);
        };
//传入标签
var department = get_selected($("#mslt_department"));
//$(this)是一个JQuery对象
var department = get_selected($(this));



jQuery中this与$(this)的区别

//这里的this其实是一个Html 元素(textbox),textbox有text属性
$("#textbox").hover(   
      function() {   
           this.title = "Test";   
      },   
      fucntion() {   
          this.title = "OK”;   
      }   
);

//$(this)是一个JQuery对象,而jQuery对象沒有title 属性,JQuery拥有attr()方法可以get/set DOM对象的属性
 function() {   
         $(this).attr(’title’, ‘Test’);   
      }

// 错误的写法
 $("#textbox").hover(   
           function() {   
              $(this).title = "Test";   
           },   
           function() {   
              $(this).title = "OK";   
           }   
    ); 

 原文出处:http://www.cnblogs.com/OnlyDreams/p/4143437.html

posted on 2014-12-04 17:42  VincentZhu  阅读(4961)  评论(0编辑  收藏  举报