Want to get data attribute value from selected dropdown option.
<select name="selection" id="mySelect">
<option value="21" data-rc="25" data-clnc="10">Treatment</option>
</select>
var rc = ? //value of data-rc
var clnc = ? //value of data-clnc
No jQuery please only JavaScript :)
You can read them out via dataset property.
Or, if you want to get the values of the selected option:
You can do that with jquery selector
$(selector).find("option:selected").data("rc") for rc and clnc for clnc where selector is your "select" tag id/class
Check this working pen
working pen
suppose we have a select field
Now we will get the select list and its selected option
Now we have the selected option we can get its attribtues
attrs is the attributes array you can get attribtues by index you want.
Or you can get attribtues by