lakeIn231
lakeIn231

Reputation: 1295

Remove item from Option for Select

I have an option for select that holds the following values:

enter image description here

I am wanting to remove the item "Paul Chemello". So I have this:

$('secondary-case-managers option[value="Paul Chemello"]').remove();

But it is not removing it. Any ideas? Here is my Javascript:

$(document).ready(function () {
    var selectedOption = $("#duplicate_claim_case_manager").val();
    if(selectedOption == "Case Manager") {
        $("[for='duplicate_claim_manager_secondary']").css({display: "block"})
        $("#secondary-case-managers").css({display: "block"})
    }
});
$('secondary-case-managers option[value="Case Manager"]').remove();

HAML:

  = select_tag('duplicate_claim_manager_secondary', options_for_select(@case_managers_drop_down, config.configuration_value),name: "config[#{config.id}]", :include_blank => true, :id=> "secondary-case-managers", :style=>"display:none")

Upvotes: 1

Views: 69

Answers (1)

James Hill
James Hill

Reputation: 61793

You're selector is incorrect. To reference by ID, you need to use '#':

$('#secondary-case-managers option[value="Paul Chemello"]').remove();

Additional Info

If you'd like to brush up on your selectors, you can find the jQuery docs here.

Upvotes: 3

Related Questions