I have the following code which looks at each div with class .comment
and shortens the text if more than 100 characters. Using JQuery.
Question is how to convert to native javascript, I can't find equivalents for .each()
or $(this)
var showChar = 100;
var ellipsestext = ...;
var moretext = more;
var lesstext = less;
$('.comment').each(function() {
var content = $(this).html();
if(content.length > showChar) {
var c = content.substr(0, showChar);
var h = content.substr(showChar-1, content.length - showChar);
var html = c + '<span class=moreellipses>' + ellipsestext+ ' </span><span class=morecontent><span>' + h + '</span></span>';
$(this).html(html);
}
});
Is this possible?