텍스트 상자 입력 메일박스 자동 연상 보완

8111 단어
텍스트 상자 입력 메일박스 자동 연상 보완
 DOCTYPE html>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta http-equiv="content-type" content="text/html;charset=utf-8">
        <title>title>
    head>
    <body>
        <input type="text" list="input_list" name="text" placeholder=" "/>
        <datalist id="input_list">datalist>
    body>
    <script type="text/javascript"  src="http://code.jquery.com/jquery-1.8.0.min.js">script>
    <script type="text/javascript">
        function inputList(input,list){
            var mailBox = [
                "@qq.com",
                "@sina.com",
                "@163.com",
                "@126.com",
                "@yahoo.com.cn",
                "@gmail.com",
                "@sohu.com"
            ];
            input.bind('input propertychange', function() {
                var key = input.val();
                if(key.indexOf("@") != -1){
                    key = key.slice(0,key.indexOf("@"));
                }
                var mailBoxLen = mailBox.length;
                var html = "";
                for(var i=0; i<mailBoxLen; i++){
                    html += '+ key + mailBox[i] +'">';
                }
                list.html(html);
            });
        }
        inputList($("input"),$("#input_list"));
    script>
html>

좋은 웹페이지 즐겨찾기