Home > Web Front-end > JS Tutorial > body text

js operation drop-down box

巴扎黑
Release: 2016-11-25 13:40:21
Original
1624 people have browsed it

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);//赋值
Copy after login


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template