How to get from <fw-select> the selected option text?

In a standard select, I can get the text of the selected option like this:
“$(”#myselect option:selected").text();"

Is there a way to get it from a fw-select as well?
For instance, I tried “$(”#myselect fw-select-option:selected").text();" but did not work.

1 Like

Hi Samuel,
Unfortunately, we do not have that exposed. Can you please raise a issue at “GitHub - freshworks/crayons: 🖍️ Crayons - A UI Kit comprising of web components for building Freshworks Apps!”?
We will expose a property for the text.
Meanwhile you can use JS to get the text by mapping the value with the text in your app itself.
Thanks!

2 Likes

Also, if you can share how you are populating the fw-select, we can help you get the text element.

Understood. I will raise an issue at github.
I’m using the ‘value’ attribute to get what I need.
Thank you!

1 Like

Thanks for raising an issue on the Crayons repository.

The solution that works for me is,

document.getElementById('mySelect').addEventListener('fwChange', (event) => {
  console.log(event.detail.meta.selectedOptions[0].text);
});

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.