如何使用jquery在完整日历中添加子字符串功能?
我有一个完整的日历功能,其中包含一些从json文件生成的事件。这些事件的名称很长。所以我想通过使用substring0,3功能来剪切它。我想在事件标题中使用这个子字符串函数。我应该在哪里添加子字符串以获取。。。大约4个字符之后如何使用jquery在完整日历中添加子字符串功能?,jquery,substring,fullcalendar,Jquery,Substring,Fullcalendar,我有一个完整的日历功能,其中包含一些从json文件生成的事件。这些事件的名称很长。所以我想通过使用substring0,3功能来剪切它。我想在事件标题中使用这个子字符串函数。我应该在哪里添加子字符串以获取。。。大约4个字符之后 $('#calendar').fullCalendar({ //$.fn.popover.defaults.container = 'body'; header: { left: 'prev,next',
$('#calendar').fullCalendar({
//$.fn.popover.defaults.container = 'body';
header: {
left: 'prev,next',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
contentHeight: 300,
height: 200 ,
eventRender: function(event, element) {
element.popover({
title: event.title,
placement: 'auto',
html: true,
trigger: 'hover',
animation:'true',
content: event.msg,
container: 'body'
});
$('body').on('click', function(e) {
if (!element.is(e.target) && element.has(e.target).length === 0 && $('.popover').has(e.target).length === 0)
element.popover('hide');
});
},
events: eventData[i].title.substring(0,5)+'..' // not working substring function
});
你不能用一些CSS来实现这一点吗
.popover-title {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
除非标题的长度超过200个字符,在这种情况下,您可能希望首先在源位置截断它。是否表示类似str.substring3、4的内容?它将从第三个字符中提取4个字符。@user26409021是的,仅此而已。。如何在事件中实现?