如何使用JavaScript显示或隐藏<select>的<option>?</select> </option>

时间:2010-09-25 15:09:49

标签: javascript html html-select

我想做&lt;的选项选择&gt;通过程序(JS)显示或隐藏,是否可能?

就像StackOverFlow首页中的有趣标签一样,当你输入一些单词时,下拉列表会展开并给你建议。

ps.我知道StackOverFlow在这种情况下没有使用select,无论如何只是以它为例。

2 个答案:

答案 0 :(得分:1)

您可以在options的{​​{1}}集合中添加或删除项目。

以下是删除一个项目并添加另一个项目的示例:

select

答案 1 :(得分:0)

function getCatListdef(sel)
{
    var index = ajax.length;
    ajax[index] = new sack();
     ajax[index].requestFile = 'data.php?cat_code='+sel;
     ajax[index].onCompletion = function(){ createCities(index) };  
    ajax[index].runAJAX();    
}
相关问题