break word for new line
// Assuming eventTitle is "Congressional Road"
var maxLength = 10; // Adjust this value according to your needs
// Check if the eventTitle length exceeds the maximum length
if (eventTitle.length > maxLength) {
// Split the eventTitle into words
var words = eventTitle.split(' ');
// Concatenate the first word with a line break after it, and join the rest of the words
var truncatedTitle = words[0] + ' <br>' + words.slice(1).join(' ');
// Assign the truncated title with Tailwind CSS classes to ensure line break
var truncatedTitleWithBreak = '<span class="whitespace-normal break-words" style="cursor: pointer;">❌</span> ' + truncatedTitle;
// Assign the truncated title with line breaks to the innerHTML of the span element
eventElement.innerHTML = truncatedTitleWithBreak;
} else {
// If the length is within the limit, simply assign the eventTitle to the innerHTML
eventElement.innerHTML = '<span class="whitespace-normal break-words" style="cursor: pointer;">❌</span> ' + eventTitle;
}
break word for new line // Assuming eventTitle is "Congressional Road" var maxLength = 10; // Adjust this value according to your needs