Get only the text of the option selected in the sp-dropdown

Hello everyone, how to show only the text of the selected item in the sp-dropdown?
html:

  <sp-dropdown id="list_MD"  placeholder="Make a selection..." style="width: 320px">
    <sp-menu slot="options">
        <sp-menu-item> Img_001 </sp-menu-item>
        <sp-menu-item> Img_002 </sp-menu-item>
        <sp-menu-item> Img_003 </sp-menu-item>
      </sp-menu>
</sp-dropdown>

js:

   var e = document.getElementById("list_MD");
   app.showAlert(e.options[e.selectedIndex].text);

That didn’t work, could someone find the correct way?

What about e.value?

@Karmalakas Could you show me an example?

   var e = document.getElementById("list_MD");
   app.showAlert(e.value);

1 Like

@Karmalakas ! It worked perfectly, thank you for being a very kind and considerate man, I will need you here very much. I apologize to everyone in this community for approaching theoretically simple topics, but I’m migrating from extendScript to UXP and I certainly see that I have to relearn everything again. Thanks again.

1 Like