检查选择框是否为空

Joh*_*ith 1 javascript

如何使用纯JavaScript检查选择框是否为空并提醒用户"选择框包含0个项目".

Mus*_*usa 5

if (document.getElementById('select').options.length == 0) 
    alert('The selectbox contains 0 items');
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/Gf8QK/