嗨我有一個instafeed模板,現在我需要限制標題的長度。我添加到js代碼來執行它,但它不起作用。有沒有辦法使<p><i>{{caption}}</i></p>
縮短並添加省略號。文字長度限制不起作用在我instafeed模板
這裏是我的代碼:
$(function(){
$(".caption").each(function(i){
len=$(this).text().length;
if(len>10)
{
$(this).text($(this).text().substr(0,10)+'...');
}
});
});
/* Intafeed and SimplyScroll */
var feed = new Instafeed({
target: 'instagram-list',
get: 'user',
userId: 1713392078,
accessToken: '0000000',
clientId: '0000000',
limit: '30',
sortBy: 'most-recent',
link: 'true',
template: '<li><figure class="effect-honey background-black1"><figcaption><p><i class"caption">{{caption}}</i></p></figcaption><a href="{{link}}" target="_blank"><img src="{{image}}" alt"{{caption}}"/></a><span class="instagram-metadata shadow">{{likes}} <span class="instagram-like"></span></span></figure></li>',
resolution: 'low_resolution',
after: function() {
$("#instagram-list").simplyScroll({
speed: 1,
frameRate: 24,
orientation: 'horizontal',
direction: 'forwards',
})
}
})
feed.run();
它工作得很好Steven。謝謝!但是,你知道用這種方法是否可以結束這個詞,以便暗殺不會成爲屁股。 :D – 2015-03-16 23:31:34
@JoanManuelHernández根據你的補充擴展我的答案。 – 2015-03-17 15:25:01
非常感謝@史蒂芬 - 斯貝羅特它像一個魅力! – 2015-03-17 21:22:48