I'm having the oddest issue where I am fading out content on a page, but for some reason some <li>
elements aren't playing ball. These elements are children to the elements I'm fading out, so it should fade out just like the rest of the elements contents. I added an <img>
to the same parent and it fades out just fine. If I go in through the browser's console to call the li elements directly, like $(".pageDiv li").fadeOut(1000)
, it works fine. I'm rather flabbergasted.
function emptyPage(el,exArr)
{
if ($(el).children().length > 1)
{
var chld = $(el).children();
$(chld).each(function (i)
{
if ($.inArray($(chld[i]).attr("class"), exArr) == -1)
{
$(chld[i]).fadeOut(500, function () { $(chld[i]).remove(); });
}
});
}
}
Here's an HTML example:
<div class="pageDiv" style="display: block; top: calc(10% - 40px);">
<div class="tab">Videos</div>
<p>Page Title</p>
<span>
Text that Fades
<br>
<br><lu><li>Does not fade</li></lu>
<br>
<br><img src="https://sd.keepcalm-o-matic.co.uk/i-w600/its-all-going-tits-up.jpg">
<br>
<br>Image above fades, as does this text
<br>
<br><li>Does not fade</li>
</span>
</div>
Calling the following function on it: emptyPage($(".pageDiv"), ["tab"])
which otherwise works fine.
I'm probably making a very basic mistake that I'm somehow blind to. Thanks a bunch!