<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <style> #city { width: 100px; } </style> </head> <body> <select id="city"> </select> <script> var towers = { gd: { gz: { th: '天河区', fy: '番禹区' }, sz: { lg: '龙岗区', fg: '凤岗区' } }, gx: { gg: { zj: '湛江镇', qx: '桥圩镇' }, yl: { sx: '山心镇', sn: '石南镇' } }, gzhou: { gy: { nm: '南明区', by: '白云区' }, dy: { hs: '惠水县', xt: '平塘镇' } } } var a=document.getElementById('city'); var tower=towers[this.getAttribute('value')]; var towe =tower[this.getAttribute('value')]; for (var key in towe) { var b=document.createElement('option'); b.setAttribute('value',key); b.innerHTML=towe[key]; a.appendChild(b); } console.log(towe); </script> </body></html>
添加回答
举报
0/150
提交
取消