Home >Web Front-end >JS Tutorial >jQuery UI implements email input prompt example_jquery

jQuery UI implements email input prompt example_jquery

WBOY
WBOYOriginal
2016-05-16 17:25:361145browse

Effect:
jQuery UI implements email input prompt example_jquery

Copy code The code is as follows:

Using Jquery UI , js and css to be imported:



< script src="../../ui/jquery.ui.core.js">




<script> <br>var emails=["163.com","yahoo.com ","yahoo.cn","126.com","sina.com"]; <br>$( function () { <br>//Bind events for the input box<br>$( "#email" ).keyup( function(){ <br>emailInp(); <br>}); <br>}); <br>function emailiInp(){ <br>var arrs= new Array() <br>inpVal= $( "#email" ).val(); <br>//Dynamicly create a drop-down list based on the entered value <br>$.each(emails, function (index,info){ <br>if (inpVal. indexOf("@" )==-1) <br>{ <br>//No input @ <br>arrs[index]=inpVal "@" info; <br>} else { <br>//Input @ <br>arrs[index]=inpVal.substring(0,inpVal.indexOf( "@" )) "@" info; <br>} <br>}) <br>$( "#email" ).autocomplete( { <br>//Bind drop-down list content<br>source: arrs <br>}); <br>} <br></script>
Finally, a text box:

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