在 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 () { // 您的代码 });
以上就是为什么 Safari 浏览器无法触发 select 标签的点击事件?的详细内容,更多请关注php中文网其它相关文章!
版权声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系 yyfuon@163.com