<li class="tweet" style="display: list-item;"> <div class="tweet_text_1"> <i class="fa fa-twitter" aria-hidden="true"></i> </div> </li> How to check whether li>div>i>is empty or not and remove li tag on empty in jQuery, CSS?
<li class="tweet" style="display: list-item;">
<div class="tweet_text_1">
<i class="fa fa-twitter" aria-hidden="true"></i>
</div>
</li>
Not tested, but I think this might be able to do it:
var tweets = document.getElementsByClassName("tweet");
for (var i = 0; i < tweets.length; i++) {
if (tweets[i].textContent.length <= 1) {
tweets[i].parentNode.removeChild(tweets[I]);
}
}
(I said <= 1 because I think the icon might count as a character?)
patel shraddha
Software Developer @iFour Technolab Pvt Ltd
window.onload = function(){ // When the page has finished loading. $(".nested").each(function(){ // Check every "nested" class if($(this).children().length == 0){ // If this nested class has no children $(this).hide(); // This will hide it, but not alter the layout // $(this).css("display", "none"); // This will alter the layout } else{ $(this).show(); //$(this).css("display", "none"); // This will alter the layout } }