テキスト ボックスから取得した配列にデータを格納するのを手伝ってくれる人はいますか。スペースが押されたときにスペース文字の前に別のフォントの色が表示されるように、フォーマットを設計する必要があります。また、スペースの後の要素は通常どおりにする必要があります。
編集:
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
var x = 0
function abc() {
var a = new Array("a", "b", "c", "d", "e", "f", "g", ..... "h", "x", "y", "z")
document.getElementById("type").value = a[x]
var i = document.getElementById("type").value
var n = i.charAt(i.length - 1)
alert(n)
var n = i.substring(0, i.length - 1)
document.getElementById("type").value = n.concat(a[x]);
if (x >= 0) x++
if (x >= 26) x = 0
}
</script>
</head>
<body>
<!--<input type="text" name="type" id="type" size="100" onkeyup="abc()">-->
<input type="text" name="type" id="type" size="100" onkeypress="abc()">
<div id="log"></div>
別の試み:
<script>
e = jQuery.Event("keypress", {
keyCode: 32
});
jQuery('#type').bind('keydown', function (e) {
var s = e.which;
jQuery('#log').html(e.which);
if (s == 8) { //backspace
alert('back space');
}
if (s == 32) { //space bar
alert('space');
var z = document.getElementById("type").value
jQuery('#type').css({
'color': 'blue'
});
}
});
</script>
</body>
</html>