• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
keenjade
博客园    首页    新随笔    联系   管理    订阅  订阅
代码小知识点汇总

1、关于分享链接

   // 分享
    function copyImg() {
        if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) { //区分iPhone设备
            window.getSelection().removeAllRanges(); //这段代码必须放在前面否则无效
            var Url2 = document.getElementById("biaoios"); //要复制文字的节点
            var range = document.createRange(); //设置range对象
            range.selectNode(Url2); // 选中需要复制的节点
            window.getSelection().addRange(range);// 执行选中元素
            var successful = document.execCommand('copy'); // 执行 copy 操作
            window.getSelection().removeAllRanges(); // 移除选中的元素
            if (successful) {
                alert('3')
            } else {
                alert('4')
            }
        } else {
            var Url2 = document.getElementById("biao1"); //要复制文字的节点
            Url2.select(); // 选择对象
            var successful = document.execCommand("Copy"); // 执行浏览器复制命令
            if (successful) {
                alert('1')
            } else {
                alert('0')
            }
        }
    }

    function save() {
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { //判断iPhone|iPad|iPod|iOS
            $('.model').show()
        } else if (/(Android)/i.test(navigator.userAgent)) { //判断Android

        } else { //pc

        };
    }

2、关于手机号中间四位用*代替

// 电话号码
        var phone = $(".userInfo p").text()
        var tel1 = phone.replace(phone.substring(3, 7), "****")
        $(".userInfo p").text(tel1)

3、css实现跑马灯文字

// css实现跑马灯
.father{
height: 25px;
line-height: 25px;
box-sizing: border-box;
word-break: break-all;
white-space: nowrap;
overflow: hidden;
.children{
display: inline-block;
padding-left: 50%; /* 从右至左开始滚动 */
animation: marqueeTransform 16s linear infinite;
}
@keyframes marqueeTransform {
0% { transform: translate(0, 0); }
100% { transform: translate(-100%, 0); }
}
}

posted on 2019-10-30 14:28  keenjade  阅读(232)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3