2013-07-17 50 views
0

我正在設置下拉值但是它沒有插入。爲什麼?但同樣的事情,我在另一個例子中,我得到的結果。無法在jquery mobile中設置下拉值

<div data-role="fieldcontain"> 
         <label for="text-12" style="text-align:left;margin-left: 0px;"> Font Type:</label> 
         <select name="select-choice-1" id="select-choice-1" class="fontFamily_h"> 
          <option>Select Font </option> 
          <option value="AntiquaAntiqua">AntiquaAntiqua</option> 
          <option value="Arial">Arial </option> 
          <option value="Times New Roman">Times New Roman</option> 

         </select> 
        </div> 
<div data-role="fieldcontain"> 
         <label for="text-12" style="text-align:left;margin-left: 0px;">Font Size:</label> 
         <select name="select-choice-1" id="select-choice-2" class="fontSize_h">Select Size 
          <option>Select Size</option> 
          <option value="9">9 px</option> 
          <option value="10">10 px</option> 
          <option value="11">11 px</option> 
          <option value="12">12 px</option> 
          <option value="13">13 px</option> 

         </select> 
        </div> 


    $(document).on('click', '.default_h', function(event) { 
     var i =12; 
     alert("Hi"+ $('#select-choice-2').val()); getting select Size 
     $('#select-choice-1').val('Arial').selectmenu("refresh"); 
     $('#select-choice-2').val('12 px').selectmenu("refresh"); 
     alert("Hi"+ $('#select-choice-1').val()); getting Arial 
      alert("Hi"+ $('#select-choice-2').val());;getting select Size 


}); 

我越來越Arrial但在第二個例子中我沒有得到12 PX

回答

2

您需要將val()屬性設置爲實際值屬性,而不是文本

$('#select-choice-1').val('Arial').selectmenu("refresh"); 
$('#select-choice-2').val('12').selectmenu("refresh"); 
+0

可以請你檢查一下這個問題... http://stackoverflow.com/questions/17682114/why-focus-move-to-above-field-while-open-to-pop-up-in-jquery – user2563256

+0

I我無法粘貼代碼,你可以從小提琴代碼。也CSS和運行你可以找到這個問題 – user2563256