0

I have this code generated with plugin arrays categories. I need hide some specifics categories from form, like "pro", "basico" and "Todas las Provincias.

<select id="category_name" class="taxonomies-filter-widget-input tax-with-childrens" name="category_name">
<option value="0">Todas</option>
<option class="level-0" value="pro">pro</option>
<option class="level-0" value="basico">basico</option>
<option class="level-0" value="todas-las-provincias">Todas las Provincias</option>
<option class="level-0" value="alava">Álava</option>
<option class="level-0" value="albacete">Albacete</option>
<option class="level-0" value="alicante">Alicante</option>
<option class="level-0" value="almeria">Almería</option>
<option class="level-0" value="avila">Ávila</option>
<option class="level-0" value="teruel">Teruel</option>
</select>
4

4 回答 4

1
$(function() {
    var toHideValues = ["pro", "basico", "todas-las-provincias"];
    $('#category_name option').each(function() {
        var $option = $(this);
        if ($.inArray($(this).val(), toHideValues) !== -1) {
            $option.hide();
        }
    });
});

See this : http://jsfiddle.net/p6fY7/

于 2013-10-06T19:20:57.263 回答
0

Problem solved!

(function($) {
$("select > option[value='pro']").remove();
$("select > option[value='basico']").remove()
})(jQuery);
于 2013-10-06T19:21:05.077 回答
0

this would do just what you need

var el = "alava";
$('select option[value="' + el + '"]').hide();

here is a working example : http://jsfiddle.net/vrcrP/

于 2013-10-06T19:21:55.130 回答
0

this will work for you

$('.level-0').each(function(){
var value = $(this).attr('value');
if (value == 'pro' || value == 'basico' || value == 'Todas las Provincias' ) {
$(this).hide();
}
});
于 2013-10-06T19:22:17.930 回答