浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
http://www.electrictoolbox.com/jquery-add-option-select-jquery/


How to Remove All Options from a Dropdown Select Box with JavaScript

To remove all options from a dropdown select box with JavaScript, simply set the length property of the dropdown box to 0. For instance, if a dropdown select box is defined as follows:

<select name='Dropdown' id='Dropdown'>
  <option value='1'>1</option>
  <option value='2'>2</option>
</select>

Use this JavaScript to remove all the options in the dropdown select box.

document.getElementById('Dropdown').length = 0;




posted on 2010-10-30 10:05  lexus  阅读(415)  评论(0)    收藏  举报