0

ファイルを使用Backbone.jsしてバックエンドからデータを取得し、HTML に表示しています。ここで、値を正しく取得できますが、選択オプションで取得した値を表示できません。ここで何が欠けていますか?

HTML

<select class="custom-select" name="number-of-sets" id="number-of-sets">
   <option>1</option>
   <option>2</option>  
   <option>3</option>  
   <option>4</option> 
   <option>5</option>
</select>

脚本

 var c = window.setInterval(function() {
      clearInterval(c);
      $("#number-of-sets").find('option:selected').removeAttr('selected');
      $("#number-of-sets option").each(function() {
             $(this).prop("selected",false);
             if(2==$(this).val())    //say i retrieved value '2' and i got it true
               { 
                 alert("check");
                 $(this).prop("selected",true); 
                 alert("no of seats::"+$(this).val()+";"+$(this).prop("selected")); 
                 return false;  
               } 
          }); 
        }, 500); 
      this.render();
    }, 
4

0 に答える 0