用js动态添加select标签的option

来源:互联网 发布:java计算器实现 编辑:程序博客网 时间:2024/06/07 01:57
js代码:
var featureLayerURLTest=[["http://192.168.15.174:6080/arcgis/rest/services/Sample/GQYDGH/FeatureServer/0","线图层1"]];function createSelectOption(featureLayerURLTest){    var _html="";    for(var _i=0;_i<featureLayerURLTest.length;_i++){        _html=_html+"<option value='"+featureLayerURLTest[_i][0]+"'>"+featureLayerURLTest[_i][1]+"</option>";    }    $("#featureLayerOptions").append(_html);    var html=$("#featureLayerOptions");    //console.log(html);}$(function(){    createSelectOption(featureLayerURLTest);});
html代码:
<div>    <lable>选择操作图层:</lable>    <br/>    <select id="featureLayerOptions">        <option id="defaultOption" value="0">            请选择操作图层        </option>    </select></div>