Home  >  Article  >  Web Front-end  >  js operation drop-down box

js operation drop-down box

巴扎黑
巴扎黑Original
2016-11-25 13:40:211585browse

JS operation drop-down box summary:

1. Assign value to the drop-down box:

var obj = document.getElementById('city');//找到下拉框  
                obj.options.length = 0;//清空下拉框  
                var dataObj = eval("(" + data + ")");//解析后台传递的数据  
                var html = "";  
                for ( var i = 0; i < dataObj.length; i++) {//循环数据  
                        html += "<option value="+dataObj[i].fyRegionCd+">"  
                        + dataObj[i].regionNmCn + "</option>";      
                }  
                $("#city").append(html);//赋值


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn