Remove() range

  • Creatore Discussione Creatore Discussione Fabio90
  • Data di inizio Data di inizio

Fabio90

Utente Attivo
29 Feb 2012
507
0
16
Buonasera forum,
volevo chiedere se posso semplificare il codice dicendo. Rimuvi tutto da value 16 a 59 con unica istruzione..
Così è troppo macchinoso...
Grazie!
Codice:
$(".app_select_services option[value='16']").remove();
$(".app_select_services option[value='17']").remove();
$(".app_select_services option[value='18']").remove();
$(".app_select_services option[value='19']").remove();
$(".app_select_services option[value='20']").remove();
$(".app_select_services option[value='21']").remove();
$(".app_select_services option[value='22']").remove();
$(".app_select_services option[value='23']").remove();
$(".app_select_services option[value='24']").remove();
$(".app_select_services option[value='25']").remove();
$(".app_select_services option[value='26']").remove();
$(".app_select_services option[value='27']").remove();
$(".app_select_services option[value='28']").remove();
$(".app_select_services option[value='29']").remove();
$(".app_select_services option[value='30']").remove();
$(".app_select_services option[value='31']").remove();
$(".app_select_services option[value='32']").remove();
$(".app_select_services option[value='33']").remove();
$(".app_select_services option[value='34']").remove();
$(".app_select_services option[value='35']").remove();
$(".app_select_services option[value='36']").remove();
$(".app_select_services option[value='37']").remove();
$(".app_select_services option[value='38']").remove();
$(".app_select_services option[value='39']").remove();
$(".app_select_services option[value='40']").remove();
$(".app_select_services option[value='41']").remove();
$(".app_select_services option[value='42']").remove();
$(".app_select_services option[value='43']").remove();
$(".app_select_services option[value='44']").remove();
$(".app_select_services option[value='45']").remove();
$(".app_select_services option[value='46']").remove();
$(".app_select_services option[value='47']").remove();
$(".app_select_services option[value='48']").remove();
$(".app_select_services option[value='49']").remove();
$(".app_select_services option[value='50']").remove();
$(".app_select_services option[value='51']").remove();
$(".app_select_services option[value='52']").remove();
$(".app_select_services option[value='53']").remove();
$(".app_select_services option[value='54']").remove();
$(".app_select_services option[value='55']").remove();
$(".app_select_services option[value='56']").remove();
$(".app_select_services option[value='57']").remove();
$(".app_select_services option[value='58']").remove();
$(".app_select_services option[value='59']").remove();
 
Ciao, puoi usare un ciclo for
HTML:
for(var i = 16; i <= 59; i++) {
        $(".app_select_services option[value='" + i + "']").remove();
    }
 
Grazie criric..
ho inserito il tuo codice però come puoi vedere sul sito non funziona.. =(

N.B: la select è in fondo alla pagina

HTML:
<script type="text/javascript">
jQuery(document).ready(function($){

$(".appointments-confirmation-end").hide();
$(".app_services_dropdown_title").hide();

var pathname = window.location.pathname;

if(pathname.indexOf('travel/classico/') > -1){
for(var i = 14; i <= 146; i++) {
        $(".app_select_services option[value='" + i + "']").remove();
    }
}
});

</script>
 
io io numeri dal 14 al 146 non li vedo
HTML:
<option value="12">THE CLASSIC TOUR - Rumanian</option>
<option value="13">THE CLASSIC TOUR - Turkish</option>
<option value="147">LA VERONA DI DANTE - English</option>
<option value="148">LA VERONA DI DANTE - French</option>
<option value="149">LA VERONA DI DANTE - German</option>
 

Discussioni simili