I have image slider:
<ul class="slider">
<li><img src=""></li>
<li><img src=""></li>
<li><img src=""></li>
</ul>
If the length of characters is <=41
, I want to remove the li
tag. I tried the following code but its not working
var li = $(".slider ul > li");
var $img = $(".slider > ul > li img").attr("src");
if ($img == length(41)) {
li.parentNode.removeChild(li);
}
This snippet will do it:
$(".slider > ul > li img").filter(function(){
return $(this).attr('src').length <= 41;
}).closest('li').remove();