0

空の値なしですべての選択オプションを取得し、変更イベントでそれらを複製したい。これは可能ですか?

これは私のコードです:

 $(function() {
        $("#ddlSecurityQuestions1").change(function() {                     
        var index = $(this).val();
        $('#ddlSecurityQuestions2').empty();           
        $('#ddlSecurityQuestions1 option').clone().appendTo('#ddlSecurityQuestions2');            
        var otherDropDown=document.getElementById('ddlSecurityQuestions2');            
         otherDropDown.options.remove(index);             
      });
  });
4

1 に答える 1

2

これを試して:

$("#ddlSecurityQuestions1").change(function () {

    var $options = $(this).find('option').filter(function () {
        return this.value !== '';
    }).clone();

    $('#ddlSecurityQuestions2').empty();
    $options.appendTo('#ddlSecurityQuestions2');
});
于 2013-05-01T13:44:46.583 に答える