js实现select动态添加option,默认为选中状态

174 阅读1分钟

	  var JYPMObj = document.getElementById("selectedJYPM");
      if(strValue != "") {
	      if(!optionIsZT(strValue, JYPMObj)) {
		            var oOption = document.createElement("OPTION");
		    	    oOption.text=strLabel;//设置key
		    	    oOption.value=strValue;//设置value
		    	    oOption.selected = true;//设置选中状态
		    	    JYPMObj.add(oOption);
			 }
	  }