alternating buttons for expand/collapse event

Hi all! I am looking for the correct coding to allow an open button to alternate with a closed button when I expand or collapse a section on my page. The down arrow when the section is opened and the right arrow when it is closed. The focus choice on the down arrow is not holding to the onclick event, it just flickers.

Thank you for any help!


export function notesbutton_click(event) {

if ($w(‘#notesbox’).collapsed) {
$w(‘#notesbox’).expand();
}
else
$w(‘#notesbox’).collapse();
}