앱)자바스크립트 툴팁 말줄임

Posted by HULIA(휴리아)
2018. 6. 4. 14:54 프론트엔드/자바스크립트
var showLength = 20; //표시할 글자수

function abbrProcess(){
    $('div[data-toggle="tooltip"]').each(function(){
        $(this).each(function(){
            if($(this).text().length >= showLength){
                   $(this).text($(this).text().substr(0. showLength)+'...');
             }
         });
    });
}

$(document).ready(function(){
    //줄임 툴팁 적용
    abbrProcess();

});





<div class="table_box">
       <table class="table_tp">
              <caption></caption>
              <colgroup>
                        <col width="5%" />
                        <col width="15%" />
                        <col width="*" />
              </colgroup>
              <thead>
                    <tr>
                         <th class="col"><span></span></th>
                          <th class="col"><span></span></th>
                     </tr>
              </thead>
              <tbody>
                    <tr>
                         <td class="al_c"><input ></td>
                         <td class="al_c"><div data-toggle="tooltip" title="내용">내용</div></td>
                    </tr>
              </tbody>
       </table>
</div>