Last updated 4 months ago
Was this helpful?
โฉ โฉ <select>
The <select> element represents a control that provides a menu of options.
<select>
๐ html
<!-- ็จ <label> ๅ ่ฃ <select> ็ๆจ็ฑคๆๅญ่ๆดๅไธๆๅผ้ธๅฎ --> <label> <!-- <select> ๆจ็ฑคๆๅญ --> flex-direction: <!-- <select> ไธๆๅผ้ธๅฎ --> <select id="flexDirection"> <option value="row">row</option> <option value="row-reverse">row-reverse</option> <option value="column">column</option> <option value="column-reverse">column-reverse</option> </select> </label>
๐ js
// 1. ๅ ๆพๅบ id="flex-direction" ็ <select> ๅ ็ด const flexDirectionSelect = document.getElementById('flexDirection'); // 2. ็ฃ่ฝไธๆๅผ้ธๅฎ็่ฎๆด flexDirectionSelect.addEventListener('change', updateFlexbox); // 3. ๆ นๆไธๆๅผ้ธๅฎ็่ฎๆด๏ผๅ็ธๅฐๆ็ๅๆ(ๆดๆฐ flexbox style ๅฑฌๆง) function updateFlexbox() { flexContainer.style.flexDirection = flexDirectionSelect.value; }
ๅฏ็จ <select> ไพๅๆ ้ธๆ flex ็ๆ็ๆนๅผใ
โฉ โฉ
codepen โฉ