I have a datalist:
<datalist id="subjects"> <?php foreach($subjects as $v){ ?> <option data-subjectid="<?php echo $v[2]; ?>" value="<?php echo ucwords($v[1]); ?>"><?php echo ucwords($v[1]); ?></option> <?php } ?> </datalist>
What I want to do is get the value stored in the data-subjectid attribute of the selected value. What I have done so far is to call the .each() function in jQuery as follows:
//on Select Change var selectedvalue = $(this).val(); $('
Is there a better and faster way to do this?
source share