find select option by text
You are using Attribute Equals
selector which selects elements that have the specified attribute with a value exactly equal to a certain value, option elements don't have text
attributes, you can use :contains
selector instead, try this:
Select all elements that contain the specified text.
$(function(){
$('#my_button').click(function(){
var unitName = "Unit2";
$('.assUnit').find('option:contains('+unitName+')').remove();
});
});
FIDDLE
If you want to select the element that has only certain value you can use the filter
method:
$(function(){
$('#my_button').click(function(){
var unitName = "Unit2";
$('.assUnit option').filter(function() {
return $(this).text() === unitName
}).remove();
});
});
FIDDLE
You will probably have more luck with this:
$('.assUnit').find('option:contains('+unitName+')').remove();
See also: :contains() selector