<bdo id='zDfX8'></bdo><ul id='zDfX8'></ul>
<tfoot id='zDfX8'></tfoot>

    <legend id='zDfX8'><style id='zDfX8'><dir id='zDfX8'><q id='zDfX8'></q></dir></style></legend>

    <small id='zDfX8'></small><noframes id='zDfX8'>

    <i id='zDfX8'><tr id='zDfX8'><dt id='zDfX8'><q id='zDfX8'><span id='zDfX8'><b id='zDfX8'><form id='zDfX8'><ins id='zDfX8'></ins><ul id='zDfX8'></ul><sub id='zDfX8'></sub></form><legend id='zDfX8'></legend><bdo id='zDfX8'><pre id='zDfX8'><center id='zDfX8'></center></pre></bdo></b><th id='zDfX8'></th></span></q></dt></tr></i><div id='zDfX8'><tfoot id='zDfX8'></tfoot><dl id='zDfX8'><fieldset id='zDfX8'></fieldset></dl></div>

      1. jquery按长度限制文本

        时间:2023-05-30
      2. <legend id='moHjh'><style id='moHjh'><dir id='moHjh'><q id='moHjh'></q></dir></style></legend>
        <i id='moHjh'><tr id='moHjh'><dt id='moHjh'><q id='moHjh'><span id='moHjh'><b id='moHjh'><form id='moHjh'><ins id='moHjh'></ins><ul id='moHjh'></ul><sub id='moHjh'></sub></form><legend id='moHjh'></legend><bdo id='moHjh'><pre id='moHjh'><center id='moHjh'></center></pre></bdo></b><th id='moHjh'></th></span></q></dt></tr></i><div id='moHjh'><tfoot id='moHjh'></tfoot><dl id='moHjh'><fieldset id='moHjh'></fieldset></dl></div>

            <bdo id='moHjh'></bdo><ul id='moHjh'></ul>

                <tbody id='moHjh'></tbody>
              <tfoot id='moHjh'></tfoot>

            1. <small id='moHjh'></small><noframes id='moHjh'>

                1. 本文介绍了jquery按长度限制文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我可以在使用 jQuery 的多个字符之后隐藏 DIV 中的文本吗?

                  Can i hide text in a DIV after a number of characters with jQuery?

                  到目前为止,我认为它会是这样的——jQuery 会循环遍历文本,直到达到一定数量的字符.然后它将从该位置包装一个 DIV 到文本的末尾,然后可以使用 hide() 方法将其隐藏.我不确定如何插入该环绕文本.

                  So far I think it would go something like this - jQuery would cycle through the text until it gets to a certain number of characters. It would then wrap a DIV from that position to the end of the text which could then be hidden with the hide() method. I'm not sure how to insert that wrapping text.

                  也将不胜感激.

                  谢谢.

                  推荐答案

                  这样会隐藏部分文字

                  <!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" xml:lang="en" lang="en">
                  <head>
                      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                  
                      <title>untitled</title>
                      <style type="text/css" media="screen">
                          .hide{
                              display: none;
                          }
                      </style>
                      <script src="js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
                      <script type="text/javascript" charset="utf-8">
                          $(function(){
                              var $elem = $('p');         // The element or elements with the text to hide
                              var $limit = 10;        // The number of characters to show
                              var $str = $elem.html();    // Getting the text
                              var $strtemp = $str.substr(0,$limit);   // Get the visible part of the string
                              $str = $strtemp + '<span class="hide">' + $str.substr($limit,$str.length) + '</span>';  // Recompose the string with the span tag wrapped around the hidden part of it
                              $elem.html($str);       // Write the string to the DOM 
                          })
                      </script>
                  
                  </head>
                  <body>
                  <p>Some lenghty string goes here</p>
                  </body>
                  </html>
                  

                  这篇关于jquery按长度限制文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:是否可以在 Dreamweaver 中自动格式化您的代码? 下一篇:&lt;tag&gt;&lt;/tag&gt; 有什么区别?和&a

                  相关文章

                  最新文章

                2. <tfoot id='g5wIN'></tfoot>
                  <i id='g5wIN'><tr id='g5wIN'><dt id='g5wIN'><q id='g5wIN'><span id='g5wIN'><b id='g5wIN'><form id='g5wIN'><ins id='g5wIN'></ins><ul id='g5wIN'></ul><sub id='g5wIN'></sub></form><legend id='g5wIN'></legend><bdo id='g5wIN'><pre id='g5wIN'><center id='g5wIN'></center></pre></bdo></b><th id='g5wIN'></th></span></q></dt></tr></i><div id='g5wIN'><tfoot id='g5wIN'></tfoot><dl id='g5wIN'><fieldset id='g5wIN'></fieldset></dl></div>
                  <legend id='g5wIN'><style id='g5wIN'><dir id='g5wIN'><q id='g5wIN'></q></dir></style></legend>

                    <small id='g5wIN'></small><noframes id='g5wIN'>

                      • <bdo id='g5wIN'></bdo><ul id='g5wIN'></ul>