【问题标题】:Combobox with javascript values not working on iPad带有 javascript 值的组合框在 iPad 上不起作用
【发布时间】:2015-08-21 11:33:28
【问题描述】:

我有这个 Javascript

$(function () {
var $select = $(".comboboxValues");
for (i = 1; i <= 99; i++) {
    $select.append($('<option></option>').val(i).html(i))
}
});

在这个 HTML 元素上

<td class="imageClass">                                  
     <select class="comboboxValues select"></select>
</td>

使用这个 CSS

.comboboxValues
{
    font-family:Segoe UI;
    text-align:center;
}
.select
    {
        margin: 0px;
        padding: 0px 5px 0px 5px;
        border: 0px;
        outline: 0px;
        border-bottom : 1px solid #6F8393;
        color: #384046;
        background: transparent;
        -webkit-appearance: none;
        -moz-appearance: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -webkit-padding-start: 10px;
        -moz-padding-start: 10px;
        -webkit-padding-end: 10px;
        -moz-padding-end:10px;
        padding-top: 2px;
        padding-bottom: 2px;
    }

此代码用于在桌面和移动 android 上用值填充组合框,但在 iPad 上不可用。

为什么这在 iPad 上不起作用,我该如何解决?

【问题讨论】:

  • “不工作”是指 iPad 上的组合框为空,没有可供选择的选项。

标签: javascript ios css ipad combobox


【解决方案1】:

我找到了解决方案,但仍然不知道为什么会这样。我刚刚写了一个不同的 Javascript:

function fillComboboxValues() {
var comboboxCollection = document.getElementsByClassName('comboboxValues_iPad');
for (var j = 0; j < comboboxCollection.length; j++) {
    var select = comboboxCollection[j];
    for (var i = 1; i <= 99; i++) {
        var option = document.createElement('option');
        option.text = option.value = i;
        select.add(option, 0);
    }
  }
}

现在它完美运行了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-02
    • 1970-01-01
    • 2011-12-26
    • 2014-02-22
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    • 2015-05-05
    相关资源
    最近更新 更多