select的option異常的總結,selectoption總結

來源:互聯網
上載者:User

select的option異常的總結,selectoption總結

來源:http://www.ido321.com/1189.html

昨天,在項目中碰到了option顯示異常的原因,如下:

Firefox中用css控制之後效果


chrome和IE中css不奏效

代碼:

<div class="controls">         <select name="ksname" id="ksname">             <?php                 while (!!$rowDK = fetchAssoc($resultDK))                  {             ?>             <optgroup label="<?php echo $rowDK['name']; ?>">               <?php                $resultKS = queryDB("select table_dake.id,table_keshi.sid,table_keshi.name from table_dake,table_keshi                           where table_dake.name='{$rowDK['name']}' and table_keshi.sid=table_dake.id");                 while(!!$rowKS = fetchAssoc($resultKS))                 {               ?>                 <option  value ="<?php echo $rowKS['name']; ?>"><?php echo $rowKS['name']; ?></option>                                  <?php                     </optgroup>                   }                 }                 free($resultDK);                 free($resultKS);             ?>         </select>     </div>

 

調 試了很久,在網上也找了方法,最終無果,只要去請教大牛了。大牛建議我去查看一下原始碼,是不是樣式改變了?這段代碼的select部分沒有任何樣式,怎 麼會多?看了原始碼之後,樣式的確沒有多,但是每個option後面多了一個</optgroup>.又回頭看了代碼,才明白,我把< /optgroup>寫在了內迴圈中,按照我的邏輯,本應該放在外迴圈。調整之後,一切正常。

所以,調試代碼又get了一招:查看原代碼


下一篇:90個IT社區等你來挑!!

 select的option異常的總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.