step 1: get data from server side
var describe = data.description;
step2: define description threshold value to limit char
var descriptionTab = $('#description');
var descriptionThreshold = 180;
step3:if description length less than description threshold value display data in single line
if (describe.length <= descriptionThreshold) {
// If the description is short, append it directly
descriptionTab.append('<span><b>Task Description: </b>' + describe + '</span>');
}
step4: if description length greater than description threshold value display data in multiple line
else {
// If the description is too long, break it into chunks
descriptionTab.append('<span><b>Task Description: </b></span>');
for (var i = 0; i < describe.length; i += descriptionThreshold) {
var chunk = describe.substring(i, i + descriptionThreshold);
descriptionTab.append('<div>' + chunk + '</div>');
}
}
Top comments (0)