1. 程式人生 > >jquery 獲取 select 選擇框的所有 內容

jquery 獲取 select 選擇框的所有 內容

獲取的所有的內容存放到 js 陣列中

function newOptionValue(selectName){
    var ret = new Array();
$("#"+selectName+" option").each(function(){
        //遍歷所有option
var value = $(this).val();   //獲取optionvar text = $(this).text();
if(text!=''){
            var o = new element(value, text);
ret.push(o);
}
    });
return 
ret;}