最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JavaScript關于select的相關操作說明

 更新時間:2010年01月13日 03:43:44   作者:  
JavaScript關于select的相關操作參考代碼。
一、 插入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

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

相關文章

最新評論

永修县| 虹口区| 鄂托克前旗| 获嘉县| 迁安市| 汕尾市| 额尔古纳市| 于田县| 石楼县| 德钦县| 泸水县| 罗田县| 阿拉尔市| 清徐县| 阳泉市| 怀仁县| 大化| 合作市| 临沧市| 阳春市| 富宁县| 东莞市| 南靖县| 江西省| 容城县| 和政县| 繁昌县| 陈巴尔虎旗| 海林市| 大石桥市| 大化| 全椒县| 大连市| 昌都县| 大新县| 桑植县| 阜城县| 蒲江县| 额济纳旗| 亳州市| 宜宾市|