早上好,大家好,
我有一个问题,它无法正常工作。只需检查我的代码中的错误。
请给我一些建议如何修复它。我使用我的代码的方式是什么,所以我会找到结果。
请建议尽快做出正确决定的方法。当鼠标单击输入框时,如何通过id
。我的代码是对的吗?我在某个地方做错了。
其他页面上的一些代码
var $write = (function(){
var write = write();
write.init("keyboard");
//first input focus
var $firstInput = $(':input').first().focus();
write.currentElement = $firstInput;
write.currentElementCursorPosition = $('#'+id);
});
$(function(){
$(':input').on('click', function () {
var id = this.id;
var $write = id,
shift = false,
capslock = false;
$('#keyboard li').click(function(){
var $this = $(this),
character = $this.html(); // If it's a lowercase letter, nothing happens to this variable
// Shift keys
if ($this.hasClass('left-shift') || $this.hasClass('right-shift')) {
$('.letter').toggleClass('uppercase');
$('.symbol span').toggle();
shift = (shift === true) ? false : true;
capslock = false;
return false;
}
// Caps lock
if ($this.hasClass('capslock')) {
$('.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
switch ($write) {
case ('#itemNo_1'):
$write.val($write.val() + character);
$write.html(txt);
$write.autocomplete("search", txt);
break;
case ('#itemNo_2'):
alert('You are item No. 2');
break;
case ('#itemNo_3'):
alert('You are item No. 3');
break;
//default:
//alert($write);
}
});
});
});