今天遇到一个小问题,select标签清空里面的选项后,在chrome下数据任然显示,F12查看其实数据是已经没有了,在其他浏览器都没有这个问题,这个要怎么解决呢?
eg:
html:
<select name="" id="mysel"><option>111</option></select>
<button onclick="change()">change</button>
JS:
function change() {
document.getElementById("mysel").options.length = 0;
}
清空方法试了很多种,innerHTML清空,jquery的remove,empty方法等,结果都一样。
查看效果:jsfiddle上查看效果
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
Chrome 版本 52.0.2743.116 m (64-bit)下,测试你的demo,OK的。
当<select>出现一个子节点会出现这种情况,清空后调用hide()和show()方法就能显示正常了。
$("#mysel").empty();
$("#mysel").hide();
$("#mysel").show();