//js代码 $(function () { var availableTags = ["@qq.com", "@gmail.com", "@126.com", "@163.com", "@hotmail.com", "@yahoo.com", "@yahoo.com.cn", "@live.com", "@sohu.com", "@sina.com"]; var result = []; $("#txtEmail").autocomplete({ source: function (request, response) { for (var i = 0; i < availableTags.length; i++) { result.push(request.term + availableTags[i]); } response(result); result = []; } }); });
<!--html代码:--> <input id="txtEmail" type="text" placeholder="请输入您的邮箱!" />