我想在選擇框中創建循環。但我想要一個不同的選擇代碼。 我可以創建一個選擇,但我想要多個。循環選擇框值
單:with id
我想改變這種根據代碼類或多個選擇。 我給這家代碼:
<select class="foo"></select><select class="foo"></select>
和:
$(document).ready(function() {
var elm = document.getElementByClass('foo'),
df = document.createDocumentFragment();
for (var i = 0; i <= 60; i++) {
var option = document.createElement('option');
option.value = i;
option.appendChild(document.createTextNode(" " + i));
df.appendChild(option);
}
elm.appendChild(df);
});
它具有跨瀏覽器的問題你最好嘗試'document.querySelectorAll( 「富」); '而不是'getElementsByClassName',我在我的答案中使用了它 –