当我的网页加载然后在id的控制台数组上显示
但是当整个页面加载id的数组消失时
enter code here 1:https://i.stack.imgur.com/AsdWq.png
我在此图片中的主要问题
[在此输入图像说明] [2] [2]:https://i.stack.imgur.com/0Ci3I.png
这是我的代码
所以如何在var $ write = $(“:input”)中保存id。on('focus')。map((i,el)=> el.id)。get();
当它保存在$ write函数中时,值将光标放入其中。
但在其中输入一个输入框会在所有输入框中输入文本。我想输入一个和值得到一个whyen游标更新
就像我的鼠标光标在itemNo_1中所以值进入该输入框并且当itemNo_2所以值进入该输入框时。 请帮帮我。
$(function(){
var $write = $(":input").on('focus').map((i, el) => el.id).get();
shift = false,
capslock = false;
backspace = false;
console.log(Object.values($write));
$('#keyboard li').click(function(){
var $this = $(this),
character = $this.html();
// Shift keys
if ($this.hasClass('left-shift') || $this.hasClass('right-shift')) {
$('.letter').toggleClass('uppercase');
$('.symbol span').toggle();
shift = (shift === true) ? false : true;
capslock = false;
backspace = false;
return false;
}
// Caps lock
if ($this.hasClass('capslock')) {
$('.letter').toggleClass('uppercase');
capslock = true;
return false;
}
// backspace lock
if ($this.hasClass('backspace')) {
$('.letter').toggleClass('uppercase');
capslock = true;
return false;
}
// Delete
if ($this.hasClass('delete')) {
var html = $write.html(),
txt = html.substr(0, html.length - 1);
$write.html(txt);
$write.autocomplete("search", txt);
return false;
}
// Delete
// Special characters
if ($this.hasClass('symbol')) character = $('span:visible', $this).html();
if ($this.hasClass('space')) character = ' ';
if ($this.hasClass('tab')) character = "\t";
if ($this.hasClass('return')) character = "\n";
// Uppercase letter
if ($this.hasClass('uppercase')) character = character.toUpperCase();
// Remove shift once a key is clicked.
if (shift === true) {
$('.symbol span').toggle();
if (capslock === false) $('.letter').toggleClass('uppercase');
shift = false;
}
//console.log("DO IT ", character);
// Add the character
$write.val($write.val() + character);
$write.html(txt);
$write.autocomplete("search", txt);
});
});
休息代码是
这里
$(function () {
var write = write();
write.init("keyboard");
//first input focus
var $firstInput = $(":input").first().focus();
write.currentElement = $firstInput;
write.currentElementCursorPosition = 0;
});