【问题标题】:select2 fails in Firefox without a decent error messageselect2 在 Firefox 中失败,没有像样的错误消息
【发布时间】:2014-02-04 09:54:01
【问题描述】:

我在这里有一个select2 jquery 插件的功能实现: http://ffx.gelatinpixel.com/files/subs/v0.4_so.html - 在 Chrome 和 IE9 (Win7 VM) 中运行良好,但在 Firefox 中失败。

我正在从 json 文件中提取一个列表并生成要添加为 select 元素中的选项的条目,但它们没有显示出来。奇怪的是,它们的值(单击空白但突出显示的选项)仍然执行搜索/选择查询并填充下表。

我现在使用的是 Firefox 26.0。

任何建议将不胜感激,迷上了这个半天多!

【问题讨论】:

    标签: javascript jquery firefox jquery-plugins jquery-select2


    【解决方案1】:

    问题出在您的 populateDropDown 函数中:subOpt.innerText =郊区[i];

    试试这个:

    subOpt.text = suburbs[i];
    

    因为 Firefox 不支持 innerText。 Firefox support textContent not innerText

    我认为与其使用原生文档 createElement 函数,不如使用 jQuery。

    因为 jQuery 涵盖了浏览器之间的这些差异。

    【讨论】:

    • 谢谢,我会采纳这个建议的。如果 jquery 已经加载,最好使用它 - 谢谢! PS:更新以上链接以供日后参考
    • 和你一样:) RE 链接已更新 我的意思是我将示例页面从 .innerText 更新为 .text
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-29
    • 2018-05-28
    • 1970-01-01
    • 1970-01-01
    • 2010-09-21
    • 2013-01-15
    • 1970-01-01
    相关资源
    最近更新 更多