Javascript: Delete all items of select tag without for loop

Posted by Syom on Stack Overflow See other posts from Stack Overflow or by Syom
Published on 2010-05-18T16:14:13Z Indexed on 2010/05/18 16:20 UTC
Read the original article Hit count: 217

Filed under:
|
|

I have a select list:

<select id="sel">
     <option>text1</option>
     <option>text2</option>
     <option>text3</option>
     <option>text4</option>
</select>

I want to delete all items, without for loop. I tried:

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

But this doesn't work in some browsers.
Any ideas?

Thanks

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about collections