I found several solutions for hiding divs when they are empty but not in connection with a mysql retrieved value.
<button class="platform_category" id="platform_', $platform['platform_id'],'_category"><a href="', $platform['platform_url'],'" target="_tab">', $platform['platform_category1'],'</a></button>
Jquery does not hide div when there is no data in mysql-row because it thinks $platform[‘platform_category1’] is a value even though that is only the php-code to retrieve the mysql value in case there is one.
For the hiding jquery code I am using this:(if I replace the == with != it hides)
$(function() {
$('.platform_category').each(function() {
if ($(this).html() == "") {
$(this).hide();
}
});
});
Buttons with class
platform_categoryhave<a>tag as inner html, sohtml()method does not make any sense here (it will always return<a>). Trytext()instead:GOOD NOTE (from @Blazemonger): It is good to use text trimming with
$.trim()method: