1

1 つの値が 4 未満の場合に入力フィールドを入力したスクリプトに問題があります。値が 4 未満の場合、スクリプトはフィールドに入力しますが、値が選択されていないため、次のステップに進むとき、これには値がありません。分野。値が 4 より大きい場合、すべて問題ありません (値も jquery によって埋められます)。

  function compute() {
    if( parseInt($("#finish_day").val()) < 4 ) { 
      $('#return_car').children('#return_car option[value=' + $('#get_car').val() + ']').attr('selected', true).siblings().attr('disabled', true);            if  
      ($('#return_car').val()) $('#return_car').change();        
    }
    else {
       $('#get_car > option, #return_car > option').prop('disabled', false);            
       $('#three_day').hide(2000, function () {                
          $(this).remove();            
       });        
    }    
  }
  $('select#get_car').change(compute);$('input#finish_day').change(compute);
4

1 に答える 1

1
  $('#return_car').children('#return_car option[value=' + $('#get_car').val() + ']').prop('selected', true).siblings().prop('disabled', true);


  $('#return_car').children('option[value=' + $('#get_car').val() + ']').prop('selected', true).siblings().prop({disabled:true,selected:false});

解決策は、disabled:true を追加して選択することです。

于 2012-10-20T17:46:44.617 に答える