Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

jQuery.selectboxes removeOption()

leave a comment »

Base on the doc page located here http://www.texotela.co.uk/code/jquery/select/ if I wanted to remove (clear) items from a select box all I need to do is call:

$('#select_box').removeOption(/./);

But in my case I had a select box like this:

<select name="select_box" id="select_box">
    <option value="">N/A</option>
    <option value="1">Low</option>
    <option value="2">Meduim</option>
    <option value="3">High</option>
</select>

and of cause the syntax specified above doesn’t do the trick; this is how I fix it:

$('#select_box').removeOption(/(.?)/);

Was that how it should be done? oh ! by the way the shorter way

$('#select_box').empty();
Advertisements

Written by Chorn Sokun

July 28, 2009 at 3:58 pm

Posted in Tips & Tricks

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: