How to remove options from select using jQuery

We  can sort an array using this method:

  1. This is the select (HTML):
    <select name="selectBox" id="selectBox">
        <option value="option1">option1</option>
        <option value="option2">option2</option>
        <option value="option3">option3</option>
        <option value="option4">option4</option>	
    </select>
  2. How to remove the items. Just do:
    //Deleting all the items with value equals to 'X':
    $("#selectBox option[value='X']").each(function() {
        $(this).remove();
    });
    //Or:
    $("#selectBox option[value='X']").remove();

Reference link: http://stackoverflow.com/questions/375508/removing-an-item-from-a-select-box

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s