2017-03-09 46 views
0

我有一個需求,比如當我們從下拉菜單中點擊一個選項時,需要滾動到一個文本框。爲了解決這個問題,我們在jquery中使用了焦點功能,它在所有的android設備上都能正常工作,甚至在桌面ios上也能正常工作,但是在iphone 6中無法正常工作。請爲此提出任何修復建議。jquery焦點功能在iphone中不工作

下拉HTML:

<select data-val="true" data-val-required="X Field is required." id="bnkdtls-mthd1" name="FinancialInformation.PreferredUsdAccount" onchange="validateusd();" aria-required="true" aria-describedby="bnkdtls-mthd1-error" class="valid" aria-invalid="false"><option value="">CHOOSE A METHOD</option> 
    <option value="2">USD Wire Transfer</option> 
    <option value="3">USD Check to Address</option> 
</select> 

jQuery的變革事件

$("#bankdtls").on('change', '#bnkdtls-mthd1', function() { 
    if ($(this).val() == "") { 
     DisableUSDSection(); 
     DisablePrizeMoneySection(); 
    } 
    if ($(this).val() == "2") { 
     //DisablePrizeMoneySection(); 
     EnableUSDSection(); 
     $(".usdbnknm input").focus(); 
    } 
    if ($(this).val() == "3") { 
     DisableUSDSection(); 
     $(".przemnymladrs input").focus() 
    } 

}); 

目標textbot HTML:

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 textbox1 paddinglftryt0 usdbnknm"> 
    <input class="textbox-input1 valid" id="FinancialInformation_UsdBankName" name="FinancialInformation.UsdBankName" onkeyup="validateUSDBankName();" type="text" value="bank" aria-invalid="false"> 
    <div class="valdtnerror-message" id="USDBankNamevaldtnID" style="display: none;">This field cannot be blank</div> 
    <div class="valdtnerror-message" id="USDBankNamelenvaldtnID" style="display: none;">Bank Name cannot be more than 45 characters</div> 
</div> 

回答

0

是這個Safari嗎?

在文本輸入的「聚焦」方面:我敢肯定iOS默認會阻止這種行爲。您必須手動點擊輸入,然後您可以在鍵盤左上角獲得up/down箭頭來瀏覽表單。

但是,如果輸入的是在屏幕上不同的位置,你可以在屏幕導航到正確的「區域」是存在於這樣的:

//scroll to the 'top' position (minus 30 for a bit of padding) 
// of a given input over 1s 
$("html, body").animate({ 
    scrollTop: $(".przemnymladrs input").offset().top-30 
}, 1000); 
+0

嗨@scgough,感謝烏拉圭回合的答覆。但是需要用相應文本框和鍵盤中的光標聚焦的輸入字段應該彈出。 –