Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js Changing selected option by option id, class, or attribute

// Using id
const $option = $select.querySelector('#myId');

// Using classname
const $option = $select.querySelector('#mySelect .myId');

// Using data-attribute
const $option = $select.querySelector('#mySelect [data-selected="myElement"]');
Source by alvarotrigo.com #
 
PREVIOUS NEXT
Tagged: #js #Changing #selected #option #option #attribute
ADD COMMENT
Topic
Name
7+2 =