javascript select option by data-value

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply
nitiphone2021
php-forum Active User
php-forum Active User
Posts: 32
Joined: Fri Jan 08, 2021 8:10 pm

Sun Feb 28, 2021 2:02 am

Code: Select all

<div class="choices__list" role="listbox"><div id="choices--p_nationality-do-item-choice-1" class="choices__item choices__item--choice choices__placeholder choices__item--selectable" role="option" data-choice="" data-id="1" data-value="" data-select-text="ກົດເລືອກ" data-choice-selectable=""></div><div id="choices--p_nationality-do-item-choice-2" class="choices__item choices__item--choice is-selected choices__item--selectable is-highlighted" role="option" data-choice="" data-id="2" data-value="AFG" data-select-text="ກົດເລືອກ" data-choice-selectable="" aria-selected="true">Afghanistan</div><div id="choices--p_nationality-do-item-choice-3" class="choices__item choices__item--choice choices__item--selectable" role="option" data-choice="" data-id="3" data-value="ALA" data-select-text="ກົດເລືອກ" data-choice-selectable="">Åland Islands</div>

According to I have list option as the code and I want to create a javascript to select it refer by data-id
Example I want to make data-value="AFG" selected, how can i do?
Post Reply