0522作业星座

   想一上午没想出来,老师讲了十几分钟搞定了,服了

  

<body>
<select id="xz">

<option>白羊座</option>
<option>金牛座</option>
<option>双子座</option>
<option>巨蟹座</option>
<option>狮子座</option>
<option>处女座</option>
<option>天秤座</option>
<option>天蝎座</option>
<option>射手座</option>
<option>摩羯座</option>
<option>水瓶座</option>
<option>双鱼座</option>

</select>
<select id="yr">

<option class=" yr_opt">3.21-4.19</option>
<option class=" yr_opt">4.20-5.20</option>
<option class=" yr_opt">5.21-6.21</option>
<option class=" yr_opt">6.22-7.22</option>
<option class=" yr_opt">7.23-8.22</option>
<option class=" yr_opt">8.23-9.22</option>
<option class=" yr_opt">9.23-10.23</option>
<option class=" yr_opt">10.24-11.22</option>
<option class=" yr_opt">11.23-12.21</option>
<option class=" yr_opt">12.22-1.19</option>
<option class=" yr_opt">1.20-2.18</option>
<option class=" yr_opt">2.19-3.20</option>

</select>


</body>
</html>
<script>
var xz = document.getElementById("xz");
var yr = document.getElementById("yr");
var yr_opt = document.getElementsByClassName("yr_opt");
xz.onchange = function () {
var xz_slt = xz.selectedIndex;
yr.options[xz_slt].selected = true;
}



</script>

posted @ 2017-05-23 16:36  小伙子很浪  阅读(353)  评论(0编辑  收藏  举报