SLaks ' answer is already good, but I'm confused by your code.
Perhaps you want to write it in such a way
$('#topic li a').filter(function(){
return $(this).text().length > 410;
}).parent('li').addClass('wrap');
or use .each(),
$('#topic li a').each(function(){
if ($(this).text().length > 410) {
$(this).parent('li').addClass('wrap');
}
});
source
share