Home > Web Front-end > JS Tutorial > js makes the drop-down list box editable, not just selection_javascript skills

js makes the drop-down list box editable, not just selection_javascript skills

WBOY
Release: 2016-05-16 17:09:30
Original
904 people have browsed it
Copy code The code is as follows:

<script> <br>function clearOption(obj,e){ <br>var currKey=0,e=e||event; <br>currKey=e.keyCode||e.which||e.charCode; <br>if(currKey == 8){ <br>obj. options[0].text = ""; <br>} <br>} <br>function writeSelect(obj,e){ <br>var currKey=0,e=e||event; <br>currKey=e .keyCode||e.which||e.charCode; <br>obj.options[0].selected = "select"; <br>if(currKey != 8){//This place is to avoid firefox again If annoying garbled characters appear, you can try commenting this sentence to see the effect in firefox <br>obj.options[0].text = obj.options[0].text String.fromCharCode(currKey); <br>} <br>e.returnValue=false; <br>return obj.options[0].text; <br>} <br>function ttt(){ <br>var jg = document.getElementById("aa") .options[document.getElementById("aa").selectedIndex].text; <br>//Of course, you can also set the value of options in the previous writeSelect function. In this case, you can directly use value to get it out in the program<br>jQuery("#aa").empty(); <br>jQuery("#aa").append("<option value=''></option>"); <br>} <br><br></script>

Copy code The code is as follows:



Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template