[英]jquery focus not working on blur
如果驗證失敗,我正在使用jquery將焦點放在模糊的文本框上。 但它在IE中工作但沒有工作FF。 有什么建議么?
$("#inputBoxId").blur(function () {
if ($(this).val() < 10)
$("#inputBoxId").focus();
});
val()
將返回字符串,而不是數字。 嘗試轉換它應該工作:
var value = parseInt($(this).val(), 10);
if (isNaN(value) || value < 10)
$("#inputBoxId").focus();
這也將處理非數值。
//頁面可見性:
document.addEventListener('visibilitychange', function () {
if (document.hidden) {
// stop running expensive task
} else {
// page has focus, begin running task
}
});
$(this).val().length
也會給出長度
$("#inputBoxId").blur(function () {
if($(this).val().length < 10 ){
$(this).focus();
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.