为什么 Safari 浏览器无法触发 select 标签的点击事件?
在 safari 浏览器中无法触发 select 标签的点击事件?
问题描述:
在 Chrome 浏览器中,点击
代码示例:
<div class="building_select"> <div class="select_building"> <div class="left_cent">楼栋</div> <select class="tower_select" id="first_tower_select"> <optgroup disabled hidden></optgroup> <option value="0">全部</option> </select> <div class="select_room"> <div class="left_cent">房号</div> <select class="n_select" id="first_storey_select"> <optgroup disabled hidden></optgroup> <option value="0">全部层</option> </select> <select class="n_select" id="first_room_select"> <optgroup disabled hidden></optgroup> <option value="0">全部房</option> </select> </div> </div> </div>
$(document).on('click', '#first_tower_select', function () { let project_id = $("#first_project_select").val(); if (project_id) { getBuilding(project_id); } });
/* 楼栋下拉框 */ for (let k in res) { html += `<option value='` + res[k].id + `'>` + res[k].building_no + `</option>`; } $("#first_tower_select").append(html); $("#first_tower_select").find('option[value="' + oldVal + '"]').prop('selected', 'selected');
解决方法:
虽然
$(document).on('focus', '#first_tower_select', function () { // 您的代码 });