zoukankan      html  css  js  c++  java
  • 控制字数显示(隐藏省略文字特效)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>隐藏省略文字特效</title>
    </head>
    <body>
    </span>
    <div id="hutia" style=" 200px;border: 1px solid red;">
    思恋是一种病思恋是一种病思恋是一种病思恋是一种病思恋是一种病思恋是一种病思恋是一种病
    思恋是一种病思恋是一种病思恋是一种病思恋是一种病思恋是一种病思恋是一种病思恋是一种病
    思恋是一种病思恋是一种病思恋是一种病思恋是一种病思恋是一种病思恋是一种病思恋是一种病
    </div>
    </body>
    <script>
    (function(){
    var o = document.getElementById("hutia");
    var s = o.innerHTML;
    var p = document.createElement("span");
    var n = document.createElement("a");
    p.innerHTML = s.substring(0,50);
    n.innerHTML = s.length > 50 ? "...此处省略一千字" : "";
    n.href = "http://baidu.com";
    o.innerHTML = "";
    o.appendChild(p);
    o.appendChild(n);
    })();
    </script>
    </html>
  • 相关阅读:
    菜根谭#308
    菜根谭#307
    菜根谭#306
    菜根谭#305
    菜根谭#304
    菜根谭#303
    菜根谭#302
    菜根谭#301
    菜根谭#300
    菜根谭#299
  • 原文地址:https://www.cnblogs.com/ZH1132672711/p/5944864.html
Copyright © 2011-2022 走看看