js实现文字超出省略号显示时长按显示全部

元素内容超出省略号显示时长按该元素,生成toast弹窗(id:toolkitContainer),以显示全部内容

#toolkitContainer {
max-width: 150px;
position: absolute;
z-index: 999;
background-color: #f6f6f6;
border-radius: 5px;
color: #000;
padding: 5px 15px;
border: solid 1px #ddd;
opacity: .95;
font-size: 12px;
}
window.onload = () => {
initListener();
//调用
$('td').each(function() {
if($(this).width() < $(this).text().length * 14) {
$(this).addClass('toolkit');
}
});
}; //字浮动显示逻辑
var initListener = function() {
$('body').on('touchstart', '.toolkit', function(e) {
var toolkit = $('#toolkitContainer');
var body = $('body');
var _this = $(this); if(toolkit.length == 0) {
toolkit = $('<div></div>').attr('id', 'toolkitContainer')
.appendTo($('body'));
} _this.on('touchend', function() {
$('#toolkitContainer').remove(); _this.off('touchend');
_this.off('touchcancel');
}); _this.on('touchcancel', function() {
$('#toolkitContainer').remove(); _this.off('touchend');
_this.off('touchcancel');
}); toolkit.html($(this).attr('tText') || $(this).html()); if(!toolkit.html()) {
return;
} var tx = e.originalEvent.touches[0].pageX - toolkit.width() / 2;
tx = tx < 0 ? 0 : tx;
tx = tx + toolkit.width() > body.width() ? tx - toolkit.width() : tx;
var ty = e.originalEvent.touches[0].pageY - toolkit.height() - 30;
ty = ty < 0 ? 0 : ty; toolkit.css('top', ty + 'px');
toolkit.css('left', tx + 'px');
toolkit.css('opcaity', '0.2');
toolkit.show();
toolkit.animate({
opcaity: 1
}, 300);
});
};

js实现长按显示全部内容的更多相关文章

  1. js点击更多显示更多内容效果

    我写了一个简单的分段显示插件,用法很简单:1,把你要分面显示的内容的容器元素增加一个class=showMoreNChildren,并增加一个自定义属性pagesize="8" 这 ...

  2. js勾选时显示相应内容

    使用环境,一.比如用户勾选时显示一些安全方面提示“你真的要自动登录吗?这将使你下次不需要密码即可进入你的个人中心.”二.显示其他预设选项,以方便用户选择输入,比如密保问题设置,当用户不想使用自定义设置 ...

  3. easyui字典js 切换 jsp页面显示的内容

    在列表中直接切换 formatter: function (value) {var name;if(value==0){name='待审批'}else if(value==1){name='通过'}e ...

  4. 网站建设中用JS判断时间并显示不同内容

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. WinForm中遇到Label要显示的内容太长,自动换行

    很多朋友都会在开发WinForm中遇到Label要显示的内容太长,但却不能换行的问题.这里我总结了几种方法,供大家参考. 第一种是把Label的AutoSize属性设为False,手动修改Label的 ...

  6. js控制select选中显示不同表单内容

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. JS实现鼠标放在文字上面显示全部内容

    web中当我们把text等的宽固定后如果文本框中内容过多就只能看到前面部分的内容,这时我们可以用样式控制当鼠标移到文本框时显示全部内容. var pointX; var pointY; $(funct ...

  8. js 控制Div循环显示 非插件版

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. 2-ls 显示目录内容

    ls list directory contents 显示目录内容 [语法]: ls [选项] [参数] [功能介绍] ls指令用来显示目录列表,在Linux系统中有着较高的使用率.ls指令的输出信息 ...

随机推荐

  1. CentOS换yum源为国内源

    CentOS换源 yum源 备份原来的文件. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup ...

  2. error:docker-ce conflicts with 2:docker-1.13.1-74.git6e3bb8e.el7.centos.x86_64

    问题原因:安装docker之前有安装cockpit-docker服务 解决方法:卸载docker-ce [root@localhost ~]# yum list installed | grep do ...

  3. Spring Boot 加载application.properties顺序

    1.准备四份application.properties a.项目根目录下config/application.properties ,内容为:  test.user.name = a b.项目根目录 ...

  4. 【转】Extension Libraries and Loading Other Image Formats

    FROM: http://lazyfoo.net/tutorials/SDL/06_extension_libraries_and_loading_other_image_formats/index. ...

  5. DTU是怎么与PLC连接通信的

    数据采集是生产制造中最实际最频繁的需求,不管智能设备制造发展到何种程度它都是工业4.0的先决条件,也在数字化工厂当中,工人更多地是处理异常情况,调整设备.但数据采集一直是困扰着所有制造工厂的传统痛点, ...

  6. 我的 Redis 被入侵了

    好吧,我也做了回标题党,像我这么细心的同学,怎么可能让服务器被入侵呢? 其实是这样的,昨天我和一个朋友聊天,他说他自己有一台云服务器运行了 Redis 数据库,有一天突然发现数据库里的数据全没了,只剩 ...

  7. C语言经典100例-ex001

    系列文章<C语言经典100例>持续创作中,欢迎大家的关注和支持. 喜欢的同学记得点赞.转发.收藏哦- 后续C语言经典100例将会以pdf和代码的形式发放到公众号 欢迎关注:计算广告生态 即 ...

  8. Java读取Excel报错Unable to recognize OLE stream

    Unable to recognize OLE stream 的解决方法 将xlsx用excel打开并另存为2003的xls,然后再运行即可解决问题 File file = new File(&quo ...

  9. 《Python3反爬虫原理与绕过实战》作者韦世东

    可以用(k1,k2)-k1来设置,如果有重复的key,则保留key1,舍弃key2/打印appleMap{1=Apple{id=1,name=苹果1,money=3.25,num=10},2=Appl ...

  10. pandas_知识总结_基础

    # Pandas 知识点总结 # Pandas数据结构:Series 和 DataFrame import pandas as pd import numpy as np # 一,Series: # ...