Collapse/Expand elements in a dynamic page if a field in a database is empty

Hi - anyone have any idea how to do this with text? i.e. collapse text/rich text fields when there is no content?

$w("#dynamicDataset").onReady( () => { let item = $w("#dynamicDataset ").getCurrentItem();
if (!item.text)("#text153") === undefined 
{ $w("#text153").hide(); $w("#text153").collapse();//set height to 0 } 
else { $w("#text153").show() ; }
} );

I’m sure there is bunch wrong there, but would appreciate the help. There are a bunch of text elements here, so would also like to know how to write this code to check multiple text elements. Thanks!