<input id="text1" tabindex="1" onblur="invokeFunc()"/>
<input id="text2" tabindex="2" onblur="invokeFunc()"/>
function invokeFunc(){
// ajax request
alert(document.activeElement);
// this returns body element in firefox, safari and chrome.
}
tôi đang cố gắng đặt tiêu điểm tập trung vào hộp văn bản với bộ tabindex phù hợp.document.activeelement trả về nội dung
khi tôi gọi hàm onblur javascript và cố gắng lấy document.activeelement thì nó luôn trả về phần tử nội dung của tôi thay vì phần tử hoạt động, nơi tập trung.
http://molily.de/weblog/javascript-fokus-zentral liệt kê một qua trình duyệt document.activeElement chức năng. –