I'm trying to use jQuery to take the content of an element, truncate it by character length, then display the output in a new element. I've looked at a number of similar forum posts but can't get anything to work! What am I doing wrong here? (this is one of many attempts)
$('dd.event_time').each(function(){
var time = $(this).text(); //Get text content from element
var timeTrim = time.substring(0, 6); //Truncate content after 6th character
$(this).parent().append('<dd class="event-time-header">' + timeTrim + '</dd>'); //Wrap output in new element
});
Getting the element content works, so does the final step. It's just the .substring
part I'm having problems with.
I'm fairly new to jQuery by the way.