我想使用jQuery的自动完成当用户在文本框用于输入电子邮件地址输入@我想启用自动完成的jQuery用户时进入@
当用户输入@ afrer输入他的电子邮件ID域名列表像@gmail .com,hotmail.com,yahoo.com应为
已填充,以便用户可以选择它而不是从自动填充中输入。
我试过,但它不工作
我的代码是
<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var autocompOpts = {
minChars:0,
matchSubset:false,
matchContains: true,
disabled: true,
source : ["@gmail.com", "@yahoo-inc.com", "@yahoo.com", "@yahoo.co.in", "@rediff.com", "@rediffmail.com", "@hotmail.com", "@msn.com", ]
};
$("input#autocomplete").autocomplete(autocompOpts);
$("input#autocomplete").bind('keyup', function(event) {
if(event.shiftKey==1)
{
if(event.keyCode==50)
{
$("input#autocomplete").autocomplete("option", "disabled", false);
var opt = $("input#autocomplete").autocomplete("option", "disabled");
alert(opt);
}
}
});
});
</script>
</head>
<body style="font-size:62.5%;">
<center>
<input id="autocomplete" />
</body>
</html>
人太多了,这里的格式! – RobertPitt 2010-08-27 11:25:39