Maison >interface Web >tutoriel HTML >css模拟实现selec下拉框_html/css_WEB-ITnose
<script><br /> var $$ = function (id) {<br /> return document.getElementById(id);<br />}<br />window.onload = function () {<br /> var btnSelect = $$("btn_select");<br /> var curSelect = btnSelect.getElementsByTagName("span")[0];<br /> var oSelect = btnSelect.getElementsByTagName("select")[0];<br /> var aOption = btnSelect.getElementsByTagName("option");<br /> oSelect.onchange = function () {<br /> var text=oSelect.options[oSelect.selectedIndex].text;<br /> curSelect.innerHTML = text;<br /> }<br />}<br /></script>