diskrim
diskrim

Reputation: 145

jQuery remove specific td from specific table

Cant seem to get this to work without removing all tr's and tables but one. I am trying to remove all countries except for 2 td's from this specific form table but I cant get the syntax correct for nothing.

$("table .country_id td .value").attr("name='location[country_id]'").not("select > option[value='GR']" ||  "select > option[value='CY']").remove();

Any help is appreciated.

Note: code below:

<div class="location_container">
<table class="form">
<tbody>
<tr class="country_id">
<td class="label">Country<span class="required_star">*</span></td>
<td class="value">
<select name="location[country_id]">
<option value="">Select</option>
<option value="AF">Afghanistan</option>
<option value="AX">Aland Islands</option>
... and so on

Upvotes: 0

Views: 296

Answers (2)

Adil
Adil

Reputation: 148110

Try using filter()

$(".country_id td.value [name^=location] option").filter(function(){
   return !(this.value=='GR' || this.value == CY);
}).remove();

Upvotes: 1

ferne97
ferne97

Reputation: 1073

You have the basic idea down, just think your not selector wasn't formatted properly.

$('.country_id').find('option').not('[value="GR"], [value="CY"]').remove();

jsFiddle

Upvotes: 0

Related Questions