<select name="ifentries" id="ifentries${index}" onchange="gradeChange('ifentries0')">
<option value="true" ${item.ifentries == true ? 'selected' : ''}>是</option>
<option value="false" ${item.ifentries == false ? 'selected' : ''}>否</option>
</select>
function gradeChange(id) {
console.log(id)
let myselect = document.getElementById(id) // id
let sletctIndex = myselect.selectedIndex // 选中的option的index
let selectValue = myselect.options[sletctIndex].value
console.log(selectValue)
}
原生js 获取select下拉值
最新推荐文章于 2023-05-17 16:47:23 发布