在Bootstrap模式下,代码不起作用

时间:2014-03-30 07:25:12

标签: javascript jquery twitter-bootstrap twitter-bootstrap-3

我在网站上使用Readmore.js来缩短文字。

<div id="TEST">THIS IS A TEST THIS IS A TEST THIS IS A TEST</div>

     <script>
     $('#TEST').readmore({
         speed: 250,
         maxHeight: 10,
         moreLink: '<a href="#" style="font-size:14px;color:#007096">Read More</a>',
         lessLink: '<a href="#" style="font-size:14px;color:#007096">Read Less</a>'
     });
     </script>

出于某种原因,如果我将此代码直接粘贴到我的页面上,它就会执行得很好。但是,如果我将这个完全相同的代码逐字地放在bootstrap 3模态上,它就不起作用。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我建议在使用readmore事件显示模态时附加show.bs.modal函数。 试试这个:

$(document).ready(function () {
    $('#myModal').on('shown.bs.modal', function (e) {
       $('#test').readmore({
             // your options here...
       });
    });
});
相关问题