Kann mir bitte jemand sagen, warum die keydown
Funktion von JavaScript in Internet Explorer 11 nicht funktioniert? Ich möchte nicht $(document).keydown
verwenden, da es immer feuern wird. Ich möchte die keydown
auf nur ein Textfeld beschränken.Keydown-Funktion funktioniert nicht in Internet Explorer 11
Es folgt der Code
$('#country-name').on('keydown', function(e) {
if (e.which == 40) {
var totalCountries = $("a.anchor:visible").length;
window.count = parseInt($("#counter").text());
if (window.count >= totalCountries) {
console.log('hi');
$("#counter").text("0");
$(".scroll-control")[0].focus();
e.preventDefault();
return;
}
$("a.anchor:visible")[window.count].focus();
window.count = window.count + 1;
$("#counter").text(window.count);
e.preventDefault();
console.log(window.count);
}
});
$('.country').keydown(function(e) {
if (e.which == 40) {
var totalCountries = $("a.anchor:visible").length;
window.count = parseInt($("#counter").text());
if (window.count >= totalCountries) {
console.log('hi');
$("#counter").text("0");
$(".scroll-control")[0].focus();
e.preventDefault();
return;
}
$("a.anchor:visible")[window.count].focus();
window.count = window.count + 1;
$("#counter").text(window.count);
e.preventDefault();
console.log(window.count);
}
});
Es war das Cache-Problem im Internet Explorer. Gelöst. –