具有javascript值的Combobox无法在iPad上运行(Combobox with javascript values not working on iPad)

我有这个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; }

这段代码可以在桌面和移动设备上填充组合框,而不是在iPad上。

为什么这不适用于iPad,我该如何解决?

I have this Javascript

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

on this HTML element

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

with this 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; }

This code works to fill a combobox with values on desktop and mobile android, but not on iPad.

Why is this not working on iPad and how can I solve this?

最满意答案

我找到了解决方案,但仍然不知道为什么这样做。 我刚写了一个不同的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); } } }

现在它完美无缺。

I found a solution to this, but still do not know why this is working. I just wrote a different 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); } } }

And now it works perfect.

更多推荐

px,comboboxValues,iPad,select,电脑培训,计算机培训,IT培训"/> <meta name="