当有人在该文本框中键入任何内容时,我编写了一个代码来在文本字段中显示 a 到 z 但现在在该代码中,当用户按下空格键时,我需要一个一个地显示 a 到 z 并且还更改前一个字母按下空格键时的颜色所以有人可以帮我做到这一点,这是我的代码
<html>
<head>
<script>
var x=0
function type()
{
var a=newArray("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")
var i=document.getElementById("type").value
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="type()">
</body>
</html>