You just have to check whether there are any child elements in the <li>
's to be highlighted
so just adding a if construct would solve the problem
$('.refine').on('change', 'input[type="radio"]', function() {
var sortattr = $(this).val();
$(".mylist li:contains('" + sortattr + "')").each(function() {
if($(this).children().length == 0){
$(this).addClass('here');
}
});
});