当前位置:主页 > 查看内容

如何实现在下拉菜单里输入文字?

发布时间:2021-04-25 00:00| 位朋友查看

简介:如何实现在下拉菜单里输入文字? script function pp(){ se.options[2]=new Option(ok=(se.options[2])?se.options[2].innerText+String.fromCharCode (event.keyCode):String.fromCharCode(event.keyCode),"client") se.selectedIndex=2; } function edit()……

如何实现在下拉菜单里输入文字?

<script>
function pp(){
se.options[2]=new Option(ok=(se.options[2])?se.options[2].innerText+String.fromCharCode
(event.keyCode):String.fromCharCode(event.keyCode),"client")
se.selectedIndex=2;
}

function edit(){
if(se.options[2]){
if(event.keyCode==8){
var str=se.options[2].innerText;
var len=str.length;
se.options[2].innerText=str.substring(0,len-1);
if(se.options[2].innerText=="")se.remove(2);
}
if(event.keyCode==13)return false;
if(event.keyCode==32){
se.options[2].innerText+=" ";
}
}
}
</script>
<select id=se onkeypress=pp() onkeyup="edit()">
<option>
山水盈盈之输入文字
</select>


本文转载自网络,原文链接:https://m.jb51.net/article/4684.htm
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!
上一篇:如何制作关联的下拉菜单? 下一篇:没有了

推荐图文


随机推荐