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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM