I am working around with typescript in Sharepoint framework using No javascript approach. To get the dropdown text I am using the below code but it is not working:

var dept = (<HTMLElement>document.getElementById("ddlDepartment").selectedOptions[0].text) OR

var empDeptt = document.getElementById("ddlDepartment")["value"]

var selectedText = empDeptt.options[empDeptt.selectedIndex].text

Please suggest any workaround.....

1 Answer 1


HTMLElement does not have above properties, its child element "HTMLSelectElement" represents HTML Element. So you can have some changes on the code:

var DropdownList = (document.getElementById("id")) as HTMLSelectElement;

This should be able to access "selectedOptions" properties and won't go against with TypeScript.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.