Skip to content

How to get selected option attribute? #131

Answered by sa-si-dev
nimeshgorfad asked this question in Q&A
Discussion options

You must be logged in to vote

How to get selected option attribute?

To get any custom attribute, set it as customData property inside the option's object while initializing.

VirtualSelect.init({
  ele: '#sample-select',
  options: [
    { label: 'Options 1', value: '1', customData: { v1: 1 } },
    { label: 'Options 2', value: '2', customData: { v1: 2 } },
  ],
});

Use getSelectedOptions() method to get selected options details

It would return value, label, and customData properties from the options object

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sa-si-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants