Answer the question
In order to leave comments, you need to log in
What is the best way to write this condition?
Hello!
There is the following block in the layout:
<p class="fileDescription">%'file_description'%</p>
. We need to make it so that we can determine how many characters (total number) will appear between the tags <p></p>
, and if there are no characters at all, then assign this one <p> display=none.
<p class="fileDescription">Описание: <span>%'file_description'%</span></p>
Answer the question
In order to leave comments, you need to log in
p:empty {
display: none;
}
jQuery:
$(function(){
$(".fileDescription span:empty").parent().hide();
});
It is possible like this:
<?php $description = 'file_description'; ?>
<p class="fileDescription"<?php if (!strlen($description)) echo ' style="display: none"'; ?>>
Описание: <span><?php echo $description; ?></span>
</p>
<style>
.hidden {
display: none;
}
</style>
<?php $description = 'file_description'; ?>
<p class="fileDescription<?php if (!strlen($description)) echo ' hidden'; ?>">
Описание: <span><?php echo $description; ?></span>
</p>
.fileDescription:has(span:empty) {
display: none;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question