Hide Statebox when empty

Hello, please help me hide the “STATEBOX” in a dynamic page if there is no content. It shows an empty box when there is no data to show from dataset. Thank you for your help.

Here’s the preview

There is two empty statebox because there is no content in dateset

What content should be there in case it exists (how does it appear in the database, what field keys? image? text?)?
Is this box in a repeater item or regular (non-repeater) element?

Thank you for confirming with me @J. D.
It contains a plain text only.
This is a MULTISTATE BOX element. Regular element and not a repeater.

$w.onReady(() => {
$w('#dynamicDataset').onReady(() => {
const item = $w('#dynamicDataset').getCurrentItem();
if(!item?.title /*for example. Let say you're interested in the title field existence*/){
$w('#box').collapse();
}
})
})

It works THANK YOU SO MUCH!