I'm facing an issue with my script that involves input data into a div field where each div should automatically move to the next one when it reaches a certain character limit.
While the script works well when using inputs, I encountered a problem when trying to input data via a virtual keyboard and not being able to use focus. I attempted to input data to specific divs based on their classes, but switching classes once a div is full did not produce the desired result.
var a = document.getElementById("a"),
b = document.getElementById("b"),
c = document.getElementById("c");
var $write = $(".active");
$('#keyboard').click(function() {
var checka = $('#a').html().length;
var checkb = $('#b').html().length;
if (checka === 4) {
a.removeClass("active");
b.addClass("active");
} else if (checkb === 4) {
b.removeClass("active");
c.addClass("active");
}
var $this = $(this),
character = $this.html();
$(".active").html($write.html() + character);
});
$('.delete').click(function() {
var html = $write.html();
$write.html(html.substr(0, html.length - 1));
return false;
});
You can view the demo here: http://jsfiddle.net/4m5fg/456/