php实现通讯录按字母分组,通讯录首字母检索功能实现
这次给大家带来通讯录首字母检索功能实现,通讯录首字母检索功能实现的注意事项有哪些,下面就是实战案例,一起来看一下。
主要代码如下:
通讯录首字母检索
通讯录
张三
李四
王五
刘六
马七
黄八
莫九
陈十
a九
1十
黄八
今天
突然
梵蒂冈
快乐的
撒地方
官方
哦
分割
票
style.csshtml,body,p,ul,li,ol,a,input,textarea,p,dl,dt,dd{margin:0;padding:0;}
ul li{list-style: none;}
a{text-decoration: none;cursor: pointer;}
html{height: 100%;}
body{height: 100%;background: #f5f5f5;position: relative;font-family: '微软雅黑';max-width: 640px;margin:auto;}
a,input,img,textarea,span,p{outline: 0;-webkit-tap-highlight-color:rgba(255,0,0,0);}
header{
width:100%;
height: 45px;
background: #ececea;
border-bottom: 1px solid #ddd;
}
header.fixed{
position: fixed;
left: 0;
top: 0;
z-index: 99;
}
.header{
margin:0 20px;
text-align: center;
color: #4e4a49;
font-size: 1em;
height: 45px;
line-height: 45px;
position: relative;
}
#letter{
width: 100px;
height: 100px;
border-radius: 5px;
font-size: 75px;
color: #555;
text-align: center;
line-height: 100px;
background: rgba(145,145,145,0.6);
position: fixed;
left: 50%;
top: 50%;
margin:-50px 0px 0px -50px;
z-index: 99;
display: none;
}
#letter img{
width: 50px;
height: 50px;
float: left;
margin:25px 0px 0px 25px;
}
.sort_box{
width: 100%;
padding-top: 45px;
overflow: hidden;
}
.sort_list{
padding:10px 60px 10px 80px;
position: relative;
height: 40px;
line-height: 40px;
border-bottom:1px solid #ddd;
}
.sort_list .num_logo{
width: 50px;
height: 50px;
border-radius: 10px;
overflow: hidden;
position: absolute;
top: 5px;
left: 20px;
}
.sort_list .num_logo img{
width: 50px;
height: 50px;
}
.sort_list .num_name{
color: #000;
}
.sort_letter{
background-color: white;
height: 30px;
line-height: 30px;
padding-left: 20px;
color:#787878;
font-size: 14px;
border-bottom:1px solid #ddd;
}
.initials{
position: fixed;
top: 47px;
right: 0px;
height: 100%;
width: 15px;
padding-right: 10px;
text-align: center;
font-size: 12px;
z-index: 99;
background: rgba(145,145,145,0);
}
.initials li img{
width: 14px;
}
sort.js$(function(){
var Initials=$('.initials');
var LetterBox=$('#letter');
Initials.find('ul').append('
ABCDEFGHIJKLMNOPQRSTUVWXYZ#');
initials();
$(".initials ul li").click(function(){
var _this=$(this);
var LetterHtml=_this.html();
LetterBox.html(LetterHtml).fadeIn();
Initials.css('background','rgba(145,145,145,0.6)');
setTimeout(function(){
Initials.css('background','rgba(145,145,145,0)');
LetterBox.fadeOut();
},1000);
var _index = _this.index()
if(_index==0){
$('html,body').animate({scrollTop: '0px'}, 300);//点击第一个滚到顶部
}else if(_index==27){
var DefaultTop=$('#default').position().top;
$('html,body').animate({scrollTop: DefaultTop+'px'}, 300);//点击最后一个滚到#号
}else{
var letter = _this.text();
if($('#'+letter).length>0){
var LetterTop = $('#'+letter).position().top;
$('html,body').animate({scrollTop: LetterTop-45+'px'}, 300);
}
}
})
var windowHeight=$(window).height();
var InitHeight=windowHeight-45;
Initials.height(InitHeight);
var LiHeight=InitHeight/28;
Initials.find('li').height(LiHeight);
})
function initials() {//排序
var SortList=$(".sort_list");
var SortBox=$(".sort_box");
SortList.sort(asc_sort).appendTo('.sort_box');//按首字母排序
function asc_sort(a, b) {
return makePy($(b).find('.num_name').text().charAt(0))[0].toUpperCase() < makePy($(a).find('.num_name').text().charAt(0))[0].toUpperCase() ? 1 : -1;
}
var initials = [];
var num=0;
SortList.each(function(i) {
var initial = makePy($(this).find('.num_name').text().charAt(0))[0].toUpperCase();
if(initial>='A'&&initial<='Z'){
if (initials.indexOf(initial) === -1)
initials.push(initial);
}else{
num++;
}
});
$.each(initials, function(index, value) {//添加首字母标签
SortBox.append('
' + value + '
');
});
if(num!=0){SortBox.append('
#
');}
for (var i =0;i
var letter=makePy(SortList.eq(i).find('.num_name').text().charAt(0))[0].toUpperCase();
switch(letter){
case "A":
$('#A').after(SortList.eq(i));
break;
case "B":
$('#B').after(SortList.eq(i));
break;
case "C":
$('#C').after(SortList.eq(i));
break;
case "D":
$('#D').after(SortList.eq(i));
break;
case "E":
$('#E').after(SortList.eq(i));
break;
case "F":
$('#F').after(SortList.eq(i));
break;
case "G":
$('#G').after(SortList.eq(i));
break;
case "H":
$('#H').after(SortList.eq(i));
break;
case "I":
$('#I').after(SortList.eq(i));
break;
case "J":
$('#J').after(SortList.eq(i));
break;
case "K":
$('#K').after(SortList.eq(i));
break;
case "L":
$('#L').after(SortList.eq(i));
break;
case "M":
$('#M').after(SortList.eq(i));
break;
case "N":
$('#N').after(SortList.eq(i));
break;
case "O":
$('#O').after(SortList.eq(i));
break;
case "P":
$('#P').after(SortList.eq(i));
break;
case "Q":
$('#Q').after(SortList.eq(i));
break;
case "R":
$('#R').after(SortList.eq(i));
break;
case "S":
$('#S').after(SortList.eq(i));
break;
case "T":
$('#T').after(SortList.eq(i));
break;
case "U":
$('#U').after(SortList.eq(i));
break;
case "V":
$('#V').after(SortList.eq(i));
break;
case "W":
$('#W').after(SortList.eq(i));
break;
case "X":
$('#X').after(SortList.eq(i));
break;
case "Y":
$('#Y').after(SortList.eq(i));
break;
case "Z":
$('#Z').after(SortList.eq(i));
break;
default:
$('#default').after(SortList.eq(i));
break;
}
};
}
最终效果:
相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!
推荐阅读:
php实现通讯录按字母分组,通讯录首字母检索功能实现相关推荐
- android通讯录首字母分类,通讯录获取首字母并以首字母归类返回
通讯录获取首字母并以首字母归类返回 效果1 - 返回首字母 效果2 - 返回拼音 代码 package com.dt.wx.miniprogram.app.util; import lombok.ex ...
- python排序输出人名,005_015 Python 人名按字母排序,首字母分组
代码如下: #encoding=utf-8 print '中国' #人名按字母排序,首字母分组 import itertools import itertools def groupnames(nam ...
- python排序输出人名_005_015 Python 人名按字母排序,首字母分组 | 学步园
代码如下: #encoding=utf-8 print '中国' #人名按字母排序,首字母分组 import itertools import itertools def groupnames(nam ...
- mysql中生成字符串对应的英文字母(拼音首字母)
mysql中生成字符串对应的英文字母(拼音首字母)的存储过程,触发器和函数 1.规则 1.1.输入字符串长度255(可变),输出字符串10(可变) 1.2.对于全英文字母或数字,输出空格后的首字符,均 ...
- PySide6中QlineEdit设置自动所有字母大写以及首字母大写的案例
pyside6中qlineEdit设置自动所有字母大写以及首字母大写的案例,方便以后查阅. import sys from PySide6.QtWidgets import *class qlinEd ...
- 简单实现通讯录中文名字按拼音首字母排序
<body> <div class="address"> <div class="address_title">通讯录< ...
- js汉语转拼音(全拼、首字母、拼音首字母)
新建js文件first_alphabet.js 1 // JavaScript Document 2 // 汉字拼音首字母列表 本列表包含了20902个汉字,用于配合 ToChineseSpell 3 ...
- vue中通过自定义指令将汉字转化为首字母大写、首字母小写、大写、小写的拼音
使用情景: 在文本框中输入内容,例如姓名 在页面中将姓名转化为姓名的拼音,包括大写拼音.小写拼音.首字母大写拼音.大写拼音缩写.小写拼音缩写 新建一个 pinyin.js 文件 这是一串又臭又长的un ...
- MySQL 汉字提取首字母、姓名首字母全拼、姓名转拼音
需要实现的功能要用函数来实现 1.汉字提取首字母 fristPinyin : 此函数是将一个中文字符串的第一个汉字转成拼音字母 (例如:"李"->l) CREATE FUNC ...
最新文章
- buffer java作用_Java NIO之Buffer的使用
- 【模型调优】风控模型调优相关知识
- python numpy 子数组_Python利用Numpy数组进行数据处理(一)
- Python学习笔记:异步IO(3)
- MySQL5.6 选项和变量整理
- c语言中函数调用的原理
- 打docker镜像_使用docker构建自己的镜像
- 演讲《云图,让阅读更精彩(Better Cloudary™, Better Reading)》
- 烟花散尽漫说无(參考资料)
- NYOJ--24素数距离问题
- atitit.编辑表单的实现最佳实践dwr jq easyui
- 汽车零部件开发工具巨头V公司全套bootloader中UDS协议栈源代码,自己完成底层外设驱动开发后,集成即可使用
- png怎么转换成jpg格式?如何转换照片格式为jpg?
- 基于MP2307的FPGA实验系统供电设计
- 2w字Python列表,全了!
- MASM32编程完善SysInfo遇到奇怪故障,真切感受全局变量和局部变量之别……
- 最新架构amd服务器cpu,AMD第一款ARM处理器正式发布!
- GBase8s数据库GET DIAGNOSTICS 语句
- 【iTerm】教程 常用命令
- coreldraw2019天气滤镜_cdr2019下载-CorelDRAW2019下载-独木成林
热门文章
- 在北京工作了两年,现在跳槽到了广州,社保公积金该如何办理?
- 《以道御术》荣耀上市,专家书评
- gitlab本地创建空文件,之后关联仓库提交文件,提交成功,但是gitlab网页中不会显示提交的文件
- 云服务器可以修改ip,云服务器的ip可以更换吗
- [LeetCode] 871. Minimum Number of Refueling Stops @ python
- JavaSE(this与super关键字;关联、依赖关系)
- 计算机引导原理,计算机启动原理与多重引导.ppt
- LAMP环境部署及搭建网校系统
- The world与Mathon2的比较
- html兼容模式下不显示图片,HTML 邮件兼容问题与解决方案