Tôi hy vọng nó sẽ giúp đỡ người khác. Tôi đã xử lý nó trong javascript. Tôi đã viết mã javascript để hiển thị nút tiếp theo ở phía bên phải của mọi đầu vào và chọn điều khiển. Khi người dùng chạm vào nút tiếp theo, nó sẽ chuyển sang điều khiển tiếp theo. Tôi đã viết mã sau đây cho việc này:
//Move to next crontrol bock
var MOVE_TO_NEXT_ID = 'aNext86332';
function bindNext() {
var allTags = document.getElementsByTagName('*');
for (var intEle = 0; intEle < allTags.length; intEle++) {
if (allTags[intEle].tagName.toLowerCase() == 'input' || allTags[intEle].tagName.toLowerCase() == 'textarea' || allTags[intEle].tagName.toLowerCase() == 'select') {
allTags[intEle].addEventListener("focus", function() {
//find next input
var nextFocus = null;
var all = document.getElementsByTagName('*');
var flag = 0;
for (var j = 0 ; j < all.length; j++) {
if (flag == 1) {
if (all[j].tagName.toLowerCase() == 'input' || all[j].tagName.toLowerCase() == 'textarea' || all[j].tagName.toLowerCase() == 'select') {
var t = allTags[j];
try {
if (t.style.display == 'none') {
continue;
}
else if (t.parentElement.style.display == 'none') {
continue;
}
else if (t.parentElement.parentElement.style.display == 'none') {
continue;
}
else if (t.parentElement.parentElement.parentElement.style.display == 'none') {
continue;
}
else {
nextFocus = allTags[j];
break;
}
}
catch (e) { }
}
}
if (this.id == all[j].id) {
flag = 1;
}
}
showNext(this, nextFocus);
});
allTags[intEle].addEventListener("blur", function() {
removeNext(this);
});
}
}
}
function moveToNextControl(me, nextObj) {
if (nextObj != null) {
nextObj.focus();
nextObj.scrollIntoView(true);
}
}
function removeNext(me) {
setTimeout(function() {
try {
var next = document.getElementById(MOVE_TO_NEXT_ID);
me.parentElement.removeChild(next);
}
catch (e) { }
}, 300);
}
function showNext(me, nextObj) {
setTimeout(function() {
var next = document.createElement("a");
next.className = 'btn btn-default animated fadeIn';
next.innerHTML = 'Next';
next.style.position = 'absolute';
next.style.zIndex = 1;
next.style.top = '0';
next.id = MOVE_TO_NEXT_ID;
next.style.left = (me.clientWidth - 40) + 'px';
next.addEventListener("click", function() {
moveToNextControl(me, nextObj);
});
me.parentElement.appendChild(next);
}, 500);
}
//End of Move to next crontrol bock
sau đó được gọi bindNext chức năng như sau:
window.onload = function() {
bindNext();
}
Nguồn
2017-09-11 19:57:43
tôi đặt một ví dụ trong câu hỏi của tôi. – user930141