效果:
复制代码 代码如下:
使用了Jquery UI ,要导入的js和css:
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<link rel="stylesheet" href="../demos.css">
<script src="/UploadFiles/2021-04-02/jquery-1.7.2.js"><script src="../../ui/jquery.ui.core.js"><script src="/UploadFiles/2021-04-02/jquery.ui.widget.js"><script src="../../ui/jquery.ui.position.js"><script src="/UploadFiles/2021-04-02/jquery.ui.autocomplete.js">
<script>
var emails=["163.com","yahoo.com","yahoo.cn","126.com","sina.com"];
$( function () {
//为输入框绑定事件
$( "#email" ).keyup( function(){
emailiInp();
});
});
function emailiInp(){
var arrs= new Array()
inpVal=$( "#email" ).val();
//根据输入的值,动态的创建下拉列表
$.each(emails, function (index,info){
if (inpVal.indexOf("@" )==-1)
{
//没有输入@
arrs[index]=inpVal+ "@" +info;
} else {
//输入@
arrs[index]=inpVal.substring(0,inpVal.indexOf( "@" ))+"@" +info;
}
})
$( "#email" ).autocomplete({
//绑定下拉列表内容
source: arrs
});
}
</script>
最后再来个文本框:
<input id="email" />
复制代码 代码如下:
使用了Jquery UI ,要导入的js和css:
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<link rel="stylesheet" href="../demos.css">
<script src="/UploadFiles/2021-04-02/jquery-1.7.2.js"><script src="../../ui/jquery.ui.core.js"><script src="/UploadFiles/2021-04-02/jquery.ui.widget.js"><script src="../../ui/jquery.ui.position.js"><script src="/UploadFiles/2021-04-02/jquery.ui.autocomplete.js">
<script>
var emails=["163.com","yahoo.com","yahoo.cn","126.com","sina.com"];
$( function () {
//为输入框绑定事件
$( "#email" ).keyup( function(){
emailiInp();
});
});
function emailiInp(){
var arrs= new Array()
inpVal=$( "#email" ).val();
//根据输入的值,动态的创建下拉列表
$.each(emails, function (index,info){
if (inpVal.indexOf("@" )==-1)
{
//没有输入@
arrs[index]=inpVal+ "@" +info;
} else {
//输入@
arrs[index]=inpVal.substring(0,inpVal.indexOf( "@" ))+"@" +info;
}
})
$( "#email" ).autocomplete({
//绑定下拉列表内容
source: arrs
});
}
</script>
最后再来个文本框:
<input id="email" />
标签:
jQuery,email输入提示
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“jQuery UI 实现email输入提示实例”评论...