首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >点JS插件不工作

点JS插件不工作
EN

Stack Overflow用户
提问于 2013-09-12 08:19:36
回答 1查看 2.3K关注 0票数 0

我想在我的Django网站上使用dotdotdot插件,但它对我不起作用。为什么?我只想在元素的末尾加上点,这是HTML头:

代码语言:javascript
复制
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script type="text/javascript" language="javascript" src="/static/mainpage/dotdotdot-1.6.5/jquery.dotdotdot.min.js"></script>
    <script type="text/javascript" language="javascript">
        $(document).ready(function() {
        $("#prispevek").dotdotdot({
            /*  The HTML to add as ellipsis. */
            ellipsis    : '... ',

            /*  How to cut off the text/html: 'word'/'letter'/'children' */
            wrap        : 'word',

            /*  Wrap-option fallback to 'letter' for long words */
            fallbackToLetter: true,

            /*  jQuery-selector for the element to keep and put after the ellipsis. */
            after       : null,

            /*  Whether to update the ellipsis: true/'window' */
            watch       : false,

            /*  Optionally set a max-height, if null, the height will be measured. */
            height      : null,

            /*  Deviation for the height-option. */
            tolerance   : 10,

            /*  Callback function that is fired after the ellipsis is added,
                receives two parameters: isTruncated(boolean), orgContent(string). */
            callback    : function( isTruncated, orgContent ) {},

            lastCharacter   : {

                /*  Remove these characters from the end of the truncated text. */
                remove      : [ ' ', ',', ';', '.', '!', '?' ],

                /*  Don't add an ellipsis if this array contains 
                    the last character of the truncated text. */
                noEllipsis  : []
            }
        });
    });
    </script>

这是css:

代码语言:javascript
复制
#prispevek

{
    height:80px;
    /*text-overflow:ellipsis;
    overflow:hidden;*/
    text-align: justify;
}

这是我的身体:内容是通过Django

代码语言:javascript
复制
{% for object in prispevky %}
    <article>
        <h1><a href="novinky/{{ object.id }}/">{{ object.nadpis }}</a></h1>
        <p id="prispevek">{{ object.text|linebreaksbr }}</p>
    </article>
{% endfor %}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-12 08:44:39

将Id更改为类,因为id是唯一的,并且在循环中追加它。

代码语言:javascript
复制
{% for object in prispevky %}
    <article>
        <h1><a href="novinky/{{ object.id }}/">{{ object.nadpis }}</a></h1>
        <p class="prispevek">{{ object.text|linebreaksbr }}</p>
    </article>
{% endfor %}

Css

代码语言:javascript
复制
.prispevek

{
    height:80px;
    /*text-overflow:ellipsis;
    overflow:hidden;*/
    text-align: justify;
}

jquery

代码语言:javascript
复制
$(document).ready(function() {
        $(".prispevek").dotdotdot({
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18759035

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档