Javascript dot-dot-JS插件不工作
我想在我的Django站点上使用DotJS插件,但它不适合我。为什么?我只想让元素的末尾有点 这是HTML头:Javascript dot-dot-JS插件不工作,javascript,jquery,django,Javascript,Jquery,Django,我想在我的Django站点上使用DotJS插件,但它不适合我。为什么?我只想让元素的末尾有点 这是HTML头: <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.
<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>
这是我的身体:内容是通过Django实现的
{% for object in prispevky %}
<article>
<h1><a href="novinky/{{ object.id }}/">{{ object.nadpis }}</a></h1>
<p id="prispevek">{{ object.text|linebreaksbr }}</p>
</article>
{% endfor %}
{%用于prispevky%中的对象]
{{object.text | linebreaksbr}
{%endfor%}
将Id更改为类,因为Id是唯一的,并且要将其附加到循环中
{% for object in prispevky %}
<article>
<h1><a href="novinky/{{ object.id }}/">{{ object.nadpis }}</a></h1>
<p class="prispevek">{{ object.text|linebreaksbr }}</p>
</article>
{% endfor %}
jquery
$(document).ready(function() {
$(".prispevek").dotdotdot({
如果您有多个
prispevky
对象,您将有多个id=“prispevek”
,这是无效的HTML。您应该在jQuery中使用id=“prispevek”
和$(“.prispevek”)
。您应该使用class=“prispevek”而不是id。@DanielRoseman您的评论是错误的。用于文本溢出:省略号的用户2771714要工作,您还需要有空白:nowrap
。你的点插件在第一个prispevek
元素上有效还是没有?对不起,伙计们,剪切粘贴错误,我的意思显然是class
。这个插件在任何元素上都不起作用,仍然不起作用。文本覆盖(文本位于另一个文本上)
.prispevek
{
height:80px;
/*text-overflow:ellipsis;
overflow:hidden;*/
text-align: justify;
}
$(document).ready(function() {
$(".prispevek").dotdotdot({