亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JavaScript關(guān)于select的相關(guān)操作說明

 更新時(shí)間:2010年01月13日 03:43:44   作者:  
JavaScript關(guān)于select的相關(guān)操作參考代碼。
一、 插入option
1、DOM方法
var oSelectYear = document.getElementById("SelectYear");
var op = document.createElement("option");
op.innerHTML = "2010";
op.value = "2010";
oSelectYear.appendChild(op);

2、new Option方法
var oSelectMonth = document.getElementById("SelectMonth");
oSelectMonth.options.add(new Option(1, 1));
oSelectMonth.options.add(new Option(2, 2));

二、 清空option
var oSelectMonth = document.getElementById("SelectMonth");
oSelectMonth.options.length = 0; //清空Select里面的options

三、 設(shè)置默認(rèn)選中option
var oSelectMonth = document.getElementById("SelectMonth");
//oSelectMonth.selectedIndex = 1; //方法一:默認(rèn)選中第二項(xiàng)
//setTimeout(function() { oSelectMonth.selectedIndex = 1; }, 0); //用setTimeout延遲是為了防止dom渲染問題
// oSelectMonth.options[1].selected = true; //方法二
oSelectMonth.options[1].setAttribute("selected", "true"); //方法三:比較推薦的用setAttribute來設(shè)置

相關(guān)文章

最新評(píng)論