Home  >  Article  >  Web Front-end  >  js method to implement Select drop-down box with input function_javascript skills

js method to implement Select drop-down box with input function_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:15:201393browse

The example in this article describes the method of using js to implement the input function of the Select drop-down box. Share it with everyone for your reference. The specific implementation method is as follows:

Implementation Method 1

Copy code The code is as follows:



JS implements input drop-down box







Implementation method two

Copy code The code is as follows:


<script><br> var Select = {<br> del : function(obj,e){<br> if((e.keyCode||e.which||e.charCode) == 8){<br> var opt = obj.options[0];<br> opt.text = opt.value = opt.value.substring(0, opt.value.length>0?opt.value.length-1:0);<br> }<br> },<br> write : function(obj,e){<br> if((e.keyCode||e.which||e.charCode) == 8)return ;<br> var opt = obj.options[0];<br> opt.selected = "selected";<br> opt.text = opt.value = String.fromCharCode(e.charCode||e.which||e.keyCode);<br> }<br> }<br> function test(){<br> alert(document.getElementById("select").value);<br> }<br> </script>

I hope this article will be helpful to everyone’s JavaScript programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn