Why is the JS script ignores tags?

Found a script spoiler from the preview of a certain number of characters, but the script JS ignores the tags, tell me why and how to fix it?

spoiler
jQuery.fn.readmore = function(options){
 // default settings
 var o = jQuery.extend({
 length: 320, //Visible number of characters
 afterLength: '...', //Text after the visible content 
 fullText:true, //Add link to show hidden text
 moreText: 'read More', //link Text to display hidden content
 lessText: 'Collapse' //text of the link after showing hidden content
},options);
 return this.each(function(){
 var 
 $el = $(this),
 elText = $.trim($el.text()),
 elLength = elText.length;
 if(elLength > o.length){ 
 var 
 textSlice = $.trim(elText.substr(0,o.length)),
 textSliced = $.trim(elText.substr(o.length));
 if(textSlice.length < o.length){
 var 
 textVisible = textSlice,
 textHidden = $.trim(elText.substr(o.length));
 }else{ 
 var 
 arrSlice = textSlice.split(' '),
 popped = arrSlice.pop(),
 textVisible = arrSlice.join(' ') + ' ',
 textHidden = popped + textSliced + ' ';
};
 var 
 $elTextHidden = $('<span>').addClass('elTextHidden').html(textHidden),
 $afterLength = $('<span>').addClass('afterLength').html(o.afterLength + ' '),
 $more = $('<span>').addClass('more').html(o.moreText);
$el.text(textVisible).append($afterLength).append($elTextHidden);
 var displayStyle = $elTextHidden.css('display');
$elTextHidden.hide();
if(o.fullText){
$el.append($more);
$more.click(function(){
if($elTextHidden.is(':hidden')){
 $elTextHidden.css({display:displayStyle}) ;
$more.html(o.lessText);
$afterLength.hide();
}else{
$elTextHidden.hide();
$more.html(o.moreText);
$afterLength.show();
};
 return false;
});
}else{
$elTextHidden.remove();
};
};
});
};</span></span></span>

Full script https://yadi.sk/d/W6b3jbJ83W88w6
June 5th 19 at 21:04
1 answer
June 5th 19 at 21:06
Solution

Find more questions by tags JavaScript